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() is not fired when app is in background.

See original GitHub issue

I am able to get logs on the console from onNotification() method when app is open (in foreground), but not getting any when app is closed (not killed).

Here is my code -

PushNotification.configure({
            // (required) Called when a remote or local notification is opened or received
            onNotification: function (notification) {
                console.log(notification);
            },
            // IOS ONLY (optional): default: all - Permissions to register.
            permissions: {
                alert: true,
                badge: true,
                sound: true
            },
            // Should the initial notification be popped automatically
            // default: true
            popInitialNotification: true,
            /**
.....

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:4
  • Comments:9

github_iconTop GitHub Comments

3reactions
iamrutvikcommented, Jul 13, 2018

React Native Push Notifications clearly states that we need to call configure outside of the React Native Lifecycle. This is very important.

https://product.farewell.io/visible-react-native-push-notifications-that-work-on-both-ios-and-android-5e90badb4a0f

https://prnt.sc/k61hz7

1reaction
tomthorntoncommented, May 7, 2020

@atebit why is this the way it is? I need to navigate and do react things in the onNotification() call back.

Read more comments on GitHub >

github_iconTop Results From Across the Web

onNotification is not calling when app is in background #1431
The main reason this is not triggered on Android is that you put .configure inside a component. Move it outside of a component...
Read more >
onNotification() is not fired when app is killed - Stack Overflow
I am not positive but when I remember correctly killing (alias force closing) an app disables the onNotification functionality in Android ...
Read more >
IONIC 5 FCM Plugin onNotification not fired when app is killed ...
IONIC 5 FCM Plugin onNotification not fired when app is ... onNotification() method isn´t fired (it works fine in background and foreground)
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 >
Receive messages in an Android app - Firebase - Google
Notification messages delivered when your app is in the background. ... but many Firebase APIs do not support being called in direct boot...
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