diff --git a/src/ios/PushPlugin.m b/src/ios/PushPlugin.m index c008e7e78..f93441b3b 100644 --- a/src/ios/PushPlugin.m +++ b/src/ios/PushPlugin.m @@ -37,6 +37,7 @@ @interface PushPlugin () @property (nonatomic, strong) NSMutableDictionary *handlerObj; @property (nonatomic, strong) UNNotification *previousNotification; +@property (nonatomic, assign) BOOL isInitialized; @property (nonatomic, assign) BOOL isInline; @property (nonatomic, assign) BOOL clearBadge; @property (nonatomic, assign) BOOL forceShow; @@ -152,6 +153,8 @@ - (void)init:(CDVInvokedUrlCommand *)command { PKPushRegistry *pushRegistry = [[PKPushRegistry alloc] initWithQueue:dispatch_get_main_queue()]; pushRegistry.delegate = self; pushRegistry.desiredPushTypes = [NSSet setWithObject:PKPushTypeVoIP]; + + self.isInitialized = YES; }]; } else { NSLog(@"[PushPlugin] VoIP missing or false"); @@ -189,11 +192,13 @@ - (void)init:(CDVInvokedUrlCommand *)command { [center setNotificationCategories:[settings categories]]; // If there is a pending startup notification, we will delay to allow JS event handlers to setup - if (self.notificationMessage) { + if (self.notificationMessage && !self.isInitialized) { dispatch_async(dispatch_get_main_queue(), ^{ [self performSelector:@selector(notificationReceived) withObject:nil afterDelay: 0.5]; }); } + + self.isInitialized = YES; }]; } }