Skip to content

Commit d348da9

Browse files
TissotTissot
authored andcommitted
Fixed registerForNotifications conditional exection
1 parent 83cd413 commit d348da9

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/ios/AppDelegate+FCMPlugin.m

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,19 @@ - (BOOL)application:(UIApplication *)application customDidFinishLaunchingWithOpt
3030
[self application:application customDidFinishLaunchingWithOptions:launchOptions];
3131

3232
NSLog(@"DidFinishLaunchingWithOptions");
33-
34-
if([FIRApp defaultApp] == nil) {
35-
[self performSelector:@selector(registerForNotifications) withObject:self afterDelay:0.3f];
36-
}
33+
[self performSelector:@selector(registerForNotifications) withObject:self afterDelay:0.3f];
3734

3835
return YES;
3936
}
4037

4138
- (void) registerForNotifications {
39+
// [BEGIN configure_firebase]
40+
if([FIRApp defaultApp] == nil) {
41+
[FIRApp configure];
42+
}
43+
// [END configure_firebase]
44+
4245
// [BEGIN register_for_notifications]
43-
[FIRApp configure];
4446
UNAuthorizationOptions authOptions = UNAuthorizationOptionAlert | UNAuthorizationOptionSound | UNAuthorizationOptionBadge;
4547
[[UNUserNotificationCenter currentNotificationCenter] requestAuthorizationWithOptions:authOptions completionHandler:^(BOOL granted, NSError * _Nullable error) {
4648
if (granted) {
@@ -51,7 +53,6 @@ - (void) registerForNotifications {
5153
NSLog(@"User Notification permission denied: %@", error.localizedDescription);
5254
}
5355
}];
54-
5556
// For iOS 10 display notification (sent via APNS)
5657
[UNUserNotificationCenter currentNotificationCenter].delegate = self;
5758
// For iOS 10 data message (sent via FCM)

0 commit comments

Comments
 (0)