Thursday, 6 June 2019

React Native OneSignal accessing push notification that initiated app start

I'm using OneSignal in my React Native iOS app and I need to access whether app was started from push notification, and if yes, I need the push payload.

I haven't seen anything in OneSignal docs. Here is my code (called immediately at app constructor):

OneSignal.init('UID_REDACTED');
OneSignal.addEventListener('ids', onIds);
OneSignal.addEventListener('received', didReceiveNotification);
OneSignal.inFocusDisplaying(2) //0: none, 1: alert, 2: notif
OneSignal.configure();  // triggers the ids event

onIds function is triggered just fine, didReceiveNotification also works perfectly if the app is already running. If the app is started from tapping a push notification, this is not called. I need to handle that case as I need to deep link the push payload to actions.

How can I handle push notifications that caused app start in React Native with OneSignal.



from React Native OneSignal accessing push notification that initiated app start

No comments:

Post a Comment