question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Callback not triggered when notification is opened and app is killed

See original GitHub issue

I’m having an issue with the onNotification callback not being called if the app is killed and the notification is clicked. Is there anyway to implement this functionality in the app?

RN -> 0.30.0 react-native-push-notification -> 2.0.2

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:15
  • Comments:37 (4 by maintainers)

github_iconTop GitHub Comments

12reactions
jakkracommented, Aug 8, 2016

Ok, so I managed to work around the issue. However, I’m running a version behind you guys, but it might still work for you. RN -> 0.29.0 react-native-push-notification -> 2.0.1

PushNotification.configure({ 
      onRegister: (response) => this.onRegister(response.token),
      onNotification: (notification) => this.handleNotification(notification),
      popInitialNotification: false, 
      ...
})

And in my onRegister method, I did:

onRegister(token) {
      PushNotification.popInitialNotification((notification) => {
            if (notification) { this.handleNotification(notification); }
      });
      ...
}
6reactions
theohdvcommented, Jul 7, 2017
PushNotification.localNotificationSchedule({
 message: "My Notification Message", // (required)
 date: new Date(Date.now() + (10 * 1000)) // in 10 secs
});
Read more comments on GitHub >

github_iconTop Results From Across the Web

Firebase push notifications callback doesn't work when app is ...
I resolved this by using the .getInitialMessage() function (This is the callback if the app is terminated. My notifications worked when the ...
Read more >
Notifications Not Shown - Mobile Push
When an app is in a Force Stopped / Force Killed state most events including FCM messages for push notifications will not be...
Read more >
Events | Notifee
Please note, for iOS, the DELIVERED event is not fired for trigger notifications when the app is in the background. App open events....
Read more >
Push notification callback behavior in android & iPhone mobiles
When the application is in dead state, offline notification callback is triggered. Default push notifications call back behavior for iPhone applications.
Read more >
react native firebase - onNotification callback is not triggered ...
Coding example for the question react native firebase - onNotification callback is not triggered when app is in foreground Android-React Native.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found