react-native-push-notification / ios

React Native Push Notification API for iOS.
MIT License
731 stars 280 forks source link

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

Open sagarhudge-eaton opened 10 months ago

sagarhudge-eaton commented 10 months 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 7 months ago

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

AdrianDAdonis commented 5 months ago

Same problem here, any update?

davepaiva commented 4 months ago

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