react-native-push-notification / ios

React Native Push Notification API for iOS.
MIT License
753 stars 288 forks source link

Foreground banner/alert notification is not working on iOS version 16.6 #423

Open sagarhudge-eaton opened 1 year ago

sagarhudge-eaton commented 1 year ago

I have implemented push notification but on latest iOS version foreground notification is not working even onNotification is not getting called ha had below changes but nothing seem to be working.

`-(void)userNotificationCenter:(UNUserNotificationCenter )center willPresentNotification:(UNNotification )notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions options))completionHandler { NSLog( @"Sagar_foreground" );

if (@available(iOS 14.0, *)) { completionHandler(UNNotificationPresentationOptionList | UNNotificationPresentationOptionBanner | UNNotificationPresentationOptionSound | UNNotificationPresentationOptionAlert | UNNotificationPresentationOptionBadge); } else { // Fallback on earlier versions completionHandler(UNNotificationPresentationOptionSound | UNNotificationPresentationOptionAlert | UNNotificationPresentationOptionBadge); }`

Replacing above snippet with below it helped to call onNotification but its executing continuously in loop.

`NSDictionary *userInfo = notification.request.content.userInfo; //Foreground NSLog(@"APP_PUSH from foreground %@", userInfo);

[RNCPushNotificationIOS didReceiveRemoteNotification:userInfo fetchCompletionHandler:^void (UIBackgroundFetchResult result){}];

if (@available(iOS 14.0, *)) { completionHandler(UNNotificationPresentationOptionSound | UNNotificationPresentationOptionBanner | UNNotificationPresentationOptionBadge); } else { completionHandler(UNNotificationPresentationOptionSound | UNNotificationPresentationOptionAlert | UNNotificationPresentationOptionBadge); }`

param240 commented 11 months ago

I do face this issue on IOS 16.6. @sagarhudge-eaton Any update on the issue?

AdrianDAdonis commented 9 months ago

Same problem here, any update?

davepaiva commented 9 months ago

I too am facing this issue with iOS 17.2 and react native 0.73.2