onNotification is not calling when app is in background
See original GitHub issueBug
When I am calling fcm server push notification api data is not showing on onNotification function.
Environment info
react-native info
output:
// paste it here
Library version: 3.4.0
Steps To Reproduce
I use the following code for recieving push notification
- Call the service from postman collection for fcm
- we got data in onNotification when app is in foreground but not in backgorund …
Describe what you expected to happen:
Reproducible sample code
PushNotification.configure({ // (optional) Called when Token is generated (iOS and Android) onRegister: function (token) { console.log(“TOKEN:”, token); thats.setState({deviceToken:token}); },
// (required) Called when a remote or local notification is opened or received
onNotification: function (notification) {
console.log('** NOTIFICATION: **', notification);
if (Platform.OS === 'ios') {
if (notification.alert.length !== 0) {
//handleNotification(notification)
notification.finish(PushNotificationIOS.FetchResult.NoData);
}
} else {
//handleNotification(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,
requestPermissions: true,
});
PushNotification.popInitialNotification((notification) => {
console.log(notification);
})
Issue Analytics
- State:
- Created 3 years ago
- Comments:68 (6 by maintainers)
Top Results From Across the Web
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 >Remote push notification doesn't wake up app
The silent push will not wake up the application if it was killed from the app ... Everything works perfectly when the app...
Read more >Receive messages in an Android app - Firebase - Google
Notification messages delivered when your app is in the background. ... or the app will need to check if it's running in direct...
Read more >Push notification doesn't open specific screen when app is ...
If it only works in the foreground or the background, ... I close app and tap on notification, nothing happens, like there is...
Read more >Events | Notifee
In any other situation a Background Event is used instead. ... (e.g. opened another app, pressed the "home" button) but not closed/quit your...
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 Free
Top 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
This is why
onNotification
is not trigger. Look at my previous message.You can’t use
notification
field with background handler. You must usedata
(and not combined withnotification
). Then if you want to notify the user, trigger a local notification.Hi,
There is no channelId defined.