react-native-push-notification / ios

React Native Push Notification API for iOS.
MIT License
734 stars 282 forks source link

Can't recived notification when foreground #295

Open anhdo9797 opened 3 years ago

anhdo9797 commented 3 years ago

dependencies:

My issue: I received Warning: Application delegate received call to -application:didReceiveRemoteNotification:fetchCompletionHandler: but the completion handler was never called. when my app has notification from fcm in the foreground

My AppDelegate.m:

` ... @implementation AppDelegate

// Required for the register event.

@end `

perfectAlways1028 commented 3 years ago

Hello, I also faced this issue, please help to give solution!!!

anhdo9797 commented 3 years ago

Hello, I also faced this issue, please help to give solution!!!

i found the solution that i added [[UNUserNotificationCenter currentNotificationCenter] setDelegate:self]; the end function didReceiveRemoteNotification. It is the line 147 in my code.

Screen Shot 2021-05-26 at 09 13 12

Adichilla commented 2 years ago

@anhdo9797 I am still getting the same

Warning: UNUserNotificationCenter delegate received call to -userNotificationCenter:didReceiveNotificationResponse:withCompletionHandler: but the completion handler was never called.

AppDelegate.m method updated

// Required for the notification event. You must call the completion handler after handling the remote notification.

salik-a commented 2 years ago

Hello, I also faced this issue, please help to give solution!!!

i found the solution that i added [[UNUserNotificationCenter currentNotificationCenter] setDelegate:self]; the end function didReceiveRemoteNotification. It is the line 147 in my code.

Screen Shot 2021-05-26 at 09 13 12

thanks a lot it worked for me

JatinPreetAxtria commented 2 years ago

Just comment the below function

// Required for localNotification event /void)userNotificationCenter:(UNUserNotificationCenter )center didReceiveNotificationResponse:(UNNotificationResponse )response withCompletionHandler:(void (^)(void))completionHandler { [RNCPushNotificationIOS didReceiveNotificationResponse:response]; }

than this Function will start working (void)application:(UIApplication )application didReceiveRemoteNotification:(NSDictionary )userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler