From d81e6b26cd2720b12eb0674b4a5162bb11c47239 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=A8=E3=83=AA=E3=82=B9?= Date: Tue, 17 Dec 2024 15:47:16 +0900 Subject: [PATCH] fix(ios): to not trigger notificationReceived when notificationMessage exists during app reload --- src/ios/PushPlugin.m | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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; }]; } }