diff --git a/ios/RNCPushNotificationIOS.m b/ios/RNCPushNotificationIOS.m index cd405bfe8..31e81b8eb 100644 --- a/ios/RNCPushNotificationIOS.m +++ b/ios/RNCPushNotificationIOS.m @@ -425,14 +425,18 @@ - (void)handleRemoteNotificationRegistrationError:(NSNotification *)notification [self sendEventWithName:@"remoteNotificationRegistrationError" body:errorDetails]; } -RCT_EXPORT_METHOD(onFinishRemoteNotification:(NSString *)notificationId fetchResult:(UIBackgroundFetchResult)result) { - RNCRemoteNotificationCallback completionHandler = self.remoteNotificationCallbacks[notificationId]; - if (!completionHandler) { - RCTLogError(@"There is no completion handler with notification id: %@", notificationId); - return; - } - completionHandler(result); - [self.remoteNotificationCallbacks removeObjectForKey:notificationId]; +RCT_EXPORT_METHOD(onFinishRemoteNotification:(NSString *)notificationId fetchResult:(UIBackgroundFetchResult)result) +{ + dispatch_async(dispatch_get_main_queue(), ^{ + RNCRemoteNotificationCallback completionHandler = self.remoteNotificationCallbacks[notificationId]; + if (!completionHandler) { + RCTLogError(@"There is no completion handler with notification id: %@", notificationId); + return; + } + + completionHandler(result); + [self.remoteNotificationCallbacks removeObjectForKey:notificationId]; + }); } /**