diff --git a/ios/RNFIRMessaging.h b/ios/RNFIRMessaging.h index 80f03c8228a6b0a6eb53c556c65499e865d5cc1b..0a07e0427e71fc17c43236119f937e4dae0dc780 100644 --- a/ios/RNFIRMessaging.h +++ b/ios/RNFIRMessaging.h @@ -9,13 +9,17 @@ @interface RNFIRMessaging : NSObject +typedef void (^RCTRemoteNotificationCallback)(UIBackgroundFetchResult result); +typedef void (^RCTWillPresentNotificationCallback)(UNNotificationPresentationOptions result); +typedef void (^RCTNotificationResponseCallback)(); + @property (nonatomic, assign) bool connectedToFCM; #if !TARGET_OS_TV -+ (void)didReceiveRemoteNotification:(nonnull NSDictionary *)userInfo fetchCompletionHandler:(nonnull void (^)(UIBackgroundFetchResult))completionHandler; ++ (void)didReceiveRemoteNotification:(nonnull NSDictionary *)userInfo fetchCompletionHandler:(nonnull RCTRemoteNotificationCallback)completionHandler; + (void)didReceiveLocalNotification:(nonnull UILocalNotification *)notification; -+ (void)didReceiveNotificationResponse:(nonnull UNNotificationResponse *)response withCompletionHandler:(nonnull void (^)())completionHandler; -+ (void)willPresentNotification:(nonnull UNNotification *)notification withCompletionHandler:(nonnull void (^)(UNNotificationPresentationOptions))completionHandler; ++ (void)didReceiveNotificationResponse:(nonnull UNNotificationResponse *)response withCompletionHandler:(nonnull RCTNotificationResponseCallback)completionHandler; ++ (void)willPresentNotification:(nonnull UNNotification *)notification withCompletionHandler:(nonnull RCTWillPresentNotificationCallback)completionHandler; #endif @end diff --git a/ios/RNFIRMesssaging.m b/ios/RNFIRMesssaging.m index cf5b9d2bf80b74ab475a6fab86b424a394075c9e..4cd92c7405ff706ab1d1ebd84e474522d5ddf78a 100644 --- a/ios/RNFIRMesssaging.m +++ b/ios/RNFIRMesssaging.m @@ -18,10 +18,6 @@ #endif -typedef void (^RCTRemoteNotificationCallback)(UIBackgroundFetchResult result); -typedef void (^RCTWillPresentNotificationCallback)(UNNotificationPresentationOptions result); -typedef void (^RCTNotificationResponseCallback)(); - NSString *const FCMNotificationReceived = @"FCMNotificationReceived"; @implementation RCTConvert (NSCalendarUnit) @@ -142,7 +138,7 @@ RCT_EXPORT_MODULE() @synthesize bridge = _bridge; -+ (void)didReceiveRemoteNotification:(nonnull NSDictionary *)userInfo fetchCompletionHandler:(RCTRemoteNotificationCallback)completionHandler { ++ (void)didReceiveRemoteNotification:(nonnull NSDictionary *)userInfo fetchCompletionHandler:(nonnull RCTRemoteNotificationCallback)completionHandler { NSMutableDictionary* data = [[NSMutableDictionary alloc] initWithDictionary: userInfo]; [data setValue:@"remote_notification" forKey:@"_notificationType"]; [data setValue:@(RCTSharedApplication().applicationState == UIApplicationStateInactive) forKey:@"opened_from_tray"]; @@ -155,7 +151,7 @@ RCT_EXPORT_MODULE() [[NSNotificationCenter defaultCenter] postNotificationName:FCMNotificationReceived object:self userInfo:data]; } -+ (void)didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(RCTNotificationResponseCallback)completionHandler ++ (void)didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(nonnull RCTNotificationResponseCallback)completionHandler { NSMutableDictionary* data = [[NSMutableDictionary alloc] initWithDictionary: response.notification.request.content.userInfo]; [data setValue:@"notification_response" forKey:@"_notificationType"]; @@ -163,7 +159,7 @@ RCT_EXPORT_MODULE() [[NSNotificationCenter defaultCenter] postNotificationName:FCMNotificationReceived object:self userInfo:@{@"data": data, @"completionHandler": completionHandler}]; } -+ (void)willPresentNotification:(UNNotification *)notification withCompletionHandler:(RCTWillPresentNotificationCallback)completionHandler ++ (void)willPresentNotification:(UNNotification *)notification withCompletionHandler:(nonnull RCTWillPresentNotificationCallback)completionHandler { NSMutableDictionary* data = [[NSMutableDictionary alloc] initWithDictionary: notification.request.content.userInfo]; [data setValue:@"will_present_notification" forKey:@"_notificationType"];