zo0r / react-native-push-notification

React Native Local and Remote Notifications
MIT License
6.73k stars 2.05k forks source link

Foreground onNotification behaviour on iOS #2389

Open abdymm opened 8 months ago

abdymm commented 8 months ago

Question

Hi guys, just want to know the correct behavior when the app is in FOREGROUND, on the onNotification currently on Android the onNotification will be triggered when a notification is received and the user taps it, but on iOS its triggered only when the user taps the notification, is this expected behaviour?

trevor-mobileup commented 7 months ago

We are also experiencing this issue. I understand it's unlikely to see this get fixed/looked into at this point, but I am commenting and getting this activity in the hopes that someone on the library has found a workaround. Migrating is a big ask for our legacy app, and we're hoping for a band-aid solution until then.

trevor-mobileup commented 7 months ago

@abdymm Through other issues we found the following two lines that we added to our AppDelegate.mm:

NSDictionary *userInfo = notification.request.content.userInfo; [RNCPushNotificationIOS didReceiveRemoteNotification:userInfo];

We added these to willPresentNotification like so:

image

Though our issue now is that the userInteraction property doesn't seem to be set properly on the notification object in the onNotification callback. Separate issue though, hope the above helps