I'm trying to implement notifications in a react-native app, on iOS, and I'm facing a strange issue. The app is able to show local notifications, and to show remote notifications coming from firebase, but it does not trigger the event "onNotification" of react-native-push-notification as expected. I have been through many forums looking for a solution but I still haven't found one yet, that's why I request your help.

After investigating, i realized that the objective-c functions "didReceiveLocalNotification" and "didReceiveRemoteNotification" are never triggered, so i supposed it is the reason why "onNotification" does not trigger either. Unfortunately I'm a total beginner in this language so I can't understand the cause of the problem.

Looking at the "didReceiveLocalNotification" documentation, I read that this function is deprecated, and that I should use "willPresentNotification" instead, but like the others it's never triggered.

For the record, I've followed this guide to handle notification in iOS : https://firebase.google.com/docs/cloud-messaging/ios/client. I'm testing on iOS 13, react-native 0.60.5, push-notifiaction-ios ^1.0.2, react-native-push-notification ^3.1.3 and react-native-firebase ^5.5.6.

AppDelegate.m

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { if ([FIRApp defaultApp] == nil) { [FIRApp configure]; [FIRMessaging messaging].delegate = self; } if ([UNUserNotificationCenter class] != nil) { // iOS 10 or later // For iOS 10 display notification (sent via APNS) [UNUserNotificationCenter currentNotificationCenter].delegate = self; UNAuthorizationOptions authOptions = UNAuthorizationOptionAlert | UNAuthorizationOptionSound | UNAuthorizationOptionBadge; [[UNUserNotificationCenter currentNotificationCenter] requestAuthorizationWithOptions:authOptions completionHandler:^(BOOL granted, NSError * _Nullable error) { // ... }]; } else { // iOS 10 notifications aren't available; fall back to iOS 8-9 notifications. UIUserNotificationType allNotificationTypes = (UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge); UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:allNotificationTypes categories:nil]; [application registerUserNotificationSettings:settings]; } [application registerForRemoteNotifications]; // Load RootView ... return YES; } // sourceURLForBridge function ... // Required to register for notifications - (void)application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings { [RNCPushNotificationIOS didRegisterUserNotificationSettings:notificationSettings]; } // Required for the register event. - (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken { [RNCPushNotificationIOS didRegisterForRemoteNotificationsWithDeviceToken:deviceToken]; } // Required for the notification event. You must call the completion handler after handling the remote notification. - (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler { // Never called [RNCPushNotificationIOS didReceiveRemoteNotification:userInfo fetchCompletionHandler:completionHandler]; } // Required for the registrationError event. - (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error { [RNCPushNotificationIOS didFailToRegisterForRemoteNotificationsWithError:error]; } // Required for the localNotification event. - (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification { // Never called [RNCPushNotificationIOS didReceiveLocalNotification:notification]; } //Called when a notification is delivered to a foreground app. -(void)userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions options))completionHandler { // Never called completionHandler(UNAuthorizationOptionSound | UNAuthorizationOptionAlert | UNAuthorizationOptionBadge); //completionHandler(UNNotificationPresentationOptionAlert); }

PushNotification and firebase configuration

function configurePushNotification(){ PushNotification.configure({ onRegister: function(token) { console.warn("TOKEN:", token); }, onNotification: function(notification) { console.warn("NOTIFICATION:", notification); // Never called notification.finish(PushNotificationIOS.FetchResult.NoData); }, permissions: { alert: true, badge: true, sound: true }, popInitialNotification: true, requestPermissions: true }); } async function checkPermission(onReady) { const enabled = await firebase.messaging().hasPermission(); if (enabled) { console.warn('checkPermission enabled'); getToken(onReady); } else { console.warn('checkPermission disabled'); requestPermission(onReady); } } async function requestPermission(onReady) { try { await firebase.messaging().requestPermission(); // User has authorised console.warn('requestPermission try'); getToken(onReady); } catch (error) { // User has rejected permissions console.error(error) console.warn('requestPermission rejected'); } } async function getToken(onReady) { fcmToken = await AsyncStorage.getItem('fcmToken'); if (!fcmToken) { fcmToken = await firebase.messaging().getToken(); if (fcmToken) { // user has a device token await AsyncStorage.setItem('fcmToken', fcmToken); } } console.warn(fcmToken) if(onReady) onReady() } class App extends React.Component { async componentDidMount() { checkPermission() configurePushNotification() } render(){ return ( // View ... ) } };

Thank you for your help !

EDIT: After investigating, I realized that these events stop working after i added Firebase/Messaging to my podfile. But according to the firebase documentation, it is not the normal behaviour. Any Idea about the reason of this ?