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,
/**
.....
it not supposed to be in the component tree, hope that helps.
same problem
@atebit Unable to understand what your wrote. Should we place PushNotification.configure() outside of the component
This might be helpful.
React Native Push Notifications clearly states that we need to call configure outside of the React Native Lifecycle. This is very important.
Having the same issue, @kckunal2612 any workaround?
Do not put PushNotification.configure inside of a React.Component, it must be outside of the React rendering lifecycle. If you put the PushNotification.configure on your index.js file and a console.log, you will see it working.
This can be closed as it's not an issue...
@atebit why is this the way it is? I need to navigate and do react things in the onNotification() call back.
Most helpful comment
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