zo0r / react-native-push-notification

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

[iOS] `onNotification` not working when app is killed after the notification is received. #2325

Closed yasircodingcrafts closed 1 year ago

yasircodingcrafts commented 1 year ago

Question

onNotification not working when app is killed after the notification is received on iOS.

Following three scenarios are working on both Android and iOS i.e

  1. When notification is received while app in Background State
  2. When notification is received while app in Foreground State
  3. When notification is received while app in Killed State

But if I kill the app after a notification is received and the app was in Foreground then the onNotification method doesn't get triggered. This is only happening in iOS while on Android it's working as expected

Can anyone please guide on what may be the problem or any workaround?

hichemBAALI commented 1 year ago

The same behavior is happening to me on Android

When app is killed and I press on the notification received, it only opens the app without any action called inside the onNotification even a console.log

yasircodingcrafts commented 1 year ago

@hichemBAALI do check your manifest files and see if it's configured correctly for Android

JoshiAditi1993 commented 1 year ago

Same with me:

When app is killed, I get the scheduled notifications. But when I open notification, onNotification method is not getting called (for both iOS and Android) Any solution for this?

yasircodingcrafts commented 1 year ago

hi @JoshiAditi1993 I will suggest that if you are using the popInitialNotification function try removing it because I was trying to fix my problem and used it but the same problem happened for me as yours.

Janviba911 commented 1 year ago

Anyone find a solution for iOS?

yasircodingcrafts commented 1 year ago

So I found out that in development mode this doesn't work as intended but when you are on production it works. No idea why that is an issue. So anyone facing this trying reproducing in production first. Thanks closing this now.

jignesh-joshi commented 1 year ago

I am facing the same issue. In Android every case redirection is working fine in iOS when the user is in the foreground or background it is working but when the user app is in a killed state user is unable to redirect to the application-specific screen I am using raect-native@0.68.4

In development it is working fine in production it is not working.