React-native-push-notification: Handling notifications when app is closed

Created on 30 Jul 2019  路  7Comments  路  Source: zo0r/react-native-push-notification

On iOS handling notifications that launch the app is relatively straightforward to use

PushNotificationIOS.getInitialNotification().then((notification) => { //bootstrapping logic })

However, what would be the equivalent API to use in this library here? The idea is that one should be able to capture the data the notification is coming with before the app is launched ( whether it exists or not ) so that then the app can appropriately route, bootstrap etc.

From my understanding of the documentation doing this isnt clear to me yet, i would be grateful if you could point me to the right direction and i shall submit a PR on the documentation as this seems to be a very common use case.

Stale

Most helpful comment

I am also having this problem. onNotification is not being called when the app is closed.

All 7 comments

Everyone keeps suggesting to use react-native-firebase instead. Surely this very common case can be handled with react-native-push-notification though.. Anyone aware?

I am also having this problem. onNotification is not being called when the app is closed.

@Return-1 is there any update on this issue? I am facing this issue in both IOS and Android.

@Return-1 is there any update on this issue? I am facing this issue in both IOS and Android.

I did something rather despicable that seems to work but in no way do i endorse this approach.

DeviceEventEmitter.addListener('pushReceived'

This will trigger on Android. For that reason im deferring the bootstrapping process for what -after testing- seems to be sufficient ( in my case 200ms ). If nothing has been received by that moment i assume no notification triggered the app to open.

This is a truly terrible solution however it seems to do the trick for now. Again, i do not endorse this and i will be migrating away from it as soon as i can myself.

Works for me in Android not in IOS.

I note that I get this on the IOS console:

Daemon Canceling Activities: {(
    com.apple.pushLaunch.xxxxxx:13400A
)}
CANCELED: com.apple.pushLaunch.xxxxxxxx:13400A at priority 10 <private>!

May be this issue is related to this:

https://stackoverflow.com/questions/53772983/ios-silent-push-notification-cancelled
https://stackoverflow.com/questions/44796613/silent-pushes-not-delivered-to-the-app-on-ios-11

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 30 days if no further activity occurs. Thank you for your contributions.

does this still not exist?

Was this page helpful?
0 / 5 - 0 ratings