onNotification is fired when application is in the background while pushing remote notifications
See original GitHub issueHi,
I am experiencing strange behaviour while pushing notifications.
It seems that when my application in the background, onNotification callback is invoked and it is even called with userInteraction: true
which does not make sense at all. It does not always invoke, and I wonder what is the right behaviour for this.
I think that onNotification should not be invoked right away, but it should invoke only after the user clicked on the push notification with userInteraction: true
.
I have not changed anything in my configuration and just used the documentation example:
// (optional) Called when Token is generated (iOS and Android)
onRegister: function(token) {
console.log( 'TOKEN:', token );
},
// (required) Called when a remote or local notification is opened or received
onNotification: function(notification) {
console.log( 'NOTIFICATION:', notification );
// process the notification
// required on iOS only (see fetchCompletionHandler docs: https://facebook.github.io/react-native/docs/pushnotificationios.html)
notification.finish(PushNotificationIOS.FetchResult.NoData);
},
// ANDROID ONLY: GCM Sender ID (optional - not required for local notifications, but is need to receive remote push notifications)
senderID: "YOUR GCM SENDER ID",
// 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,
/**
* (optional) default: true
* - Specified if permissions (ios) and token (android and ios) will requested or not,
* - if not, you must call PushNotificationsHandler.requestPermissions() later
*/
requestPermissions: true,
Did anyone encounter this? Thanks in advance!
Issue Analytics
- State:
- Created 5 years ago
- Comments:6
Top Results From Across the Web
onNotification() is not fired when app is killed - Stack Overflow
i'm using https://github.com/zo0r/react-native-push-notification to ...
Read more >Push notification in Background wo… | Apple Developer Forums
Push notification in Background works fine when App runs by Xcode, but does not work when App runs by itself.
Read more >react-native-push-notification - npm
React Native Local and Remote Notifications for iOS and Android ... changes in the application part, while localNotificationSchedule() only ...
Read more >Handling Incoming Push Notifications in AWS Amplify - Medium
AWS Amplify provides two push notification configuration functions to configure how push notifications are handled by your app: onNotification, ...
Read more >Handling Incoming Push Notifications in AWS Amplify
PushNotification.onNotification ; If the app is in the foreground ; or in the background ; handler function is called when a push notification...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I also followed the example in the documentation and I’m having a similar issue on iOS, as soon as the device receives a push notification while the app is in the background (not closed, just “minimized”), onNotification is triggered and the “userInteraction” flag is true, it doesn’t wait for the user to click on the notification.
I’m experiencing the same issue. When receiving a notification in background when app is ‘dead’ (force quit, or hasn’t been ran for a while), the app starts automatically from the background without user interaction on the notification. Would love to get this resolved! 😃