Skip to content

Commit

Permalink
fix(ios): to not trigger notificationReceived when notificationMessag…
Browse files Browse the repository at this point in the history
…e exists during app reload
  • Loading branch information
erisu committed Dec 17, 2024
1 parent b230703 commit d81e6b2
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/ios/PushPlugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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;
}];
}
}
Expand Down

0 comments on commit d81e6b2

Please sign in to comment.