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.

onNotification called only once in Android and not called again on notification open(userInteraction not updated)

See original GitHub issue

I have a function that is called on onNotification. This function checks for link that comes in data and checks for user interaction to be true - if condition passes then navigation function is called to navigate to needed screen in the app.

All this looks something like:

PushNotification.configure({
....
      onNotification: this._onNotification.bind(this),
....
});

_onNotification(notification) {
....
    if (notification && notification.userInteraction) {
      let data = notification.data || {};
      if (data && data.link) {
        //do navigation to link
      }
    }
  }

This works all good with iOS where notification.userInteraction changes from false to true on notification click and app opening. The onNotification is called once more and passes condition, therefore does the navigation. With android as far as I got from debugging the app - onNotification is called only once and only on notification being received, when you click on notification to open app - onNotification is not updated and called once more.

My current RN version is 0.39 and current react-native-push-notification version is 2.2.1

Any ideas or suggestions that would help to resolve the issue? 😃

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:9

github_iconTop GitHub Comments

7reactions
elliotstokescommented, May 4, 2017

Has there been any progress on this at all? I’m seeing the same. App open - onNotification called. App closed or in the background - Notification shown in notification center. Clicking on notification does not result in onNotification being called though.

6reactions
edmondcangcommented, Jan 26, 2017

Me also. onNotification is called ONLY WHEN the app is running on foreground

Read more comments on GitHub >

github_iconTop Results From Across the Web

React native Push Notification onNotification event not working
But onNotification function doesn't get called. I've gone through the following questions on SO but no luck. react-native push notification ...
Read more >
walbay/react-native-push-notification - npm
Called when a notification is delivered to a foreground app. ... Once the channel is created, the channel will not be update.
Read more >
Restrictions on starting activities from the background
Apps running on Android 10 or higher can start activities only when one or more of the following conditions are met: ... The...
Read more >
Push Notifications - QuickBlox Documentation
To start working with push notifications, you need to install ... (ios) and token (android and ios) will requested or not, * -...
Read more >
Push Notifications - Optimizely
ODP does not have to be your only source of push notifications. ... onNotification callback is called when a push notification gets to...
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