react-native-push-notification: On 6.0.0 foreground notification no longer appears on Android
Bug
I have the “notification_foreground” option in AndroidManifest.xml set to “true”, as I would like foreground notifications to appear.
In v5.1.1 of this package the notification appears as expected while the app is in the foreground.
When I update to 6.0.0 the notification no longer appears. Notifications continue to appear while the app is in the background ok.
When I roll back to 5.1.1 (with no other changes) the foreground notifications appear again.
Has something changed in 6.0.0 which would affect this behaviour?
Thanks
Environment info
react-native info
output:
// paste it here
Library version: 6.0.0
Steps To Reproduce
- Install 6.0.0 of this library
- Set “notification_foreground” to true in AndroidManifest.xml
- Run the app on Android
- Trigger a remote notification while the app is open in the foreground
- Don’t see the notification appear
- Roll back to 5.1.1 and repeat the steps
- See the notification appear while the app is open in the foreground …
Describe what you expected to happen:
Foreground notification behaviour doesn’t change between version 5.1.1 and 6.0.0.
Reproducible sample code
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 37
Commits related to this issue
- Prevent this issue #1671. — committed to zo0r/react-native-push-notification by Dallas62 4 years ago
Hey I’m using version 7.0.0 and I’m experiencing same problem. I’ve created my channel:
And I’m reacting to notification like this:
It works when application is in background but not when it’s in foreground. Do you know what could I be doing wrong?
I just released the version 6.1.0. In your case you can create a channel and define it as default channel for FCM notifications in
AndroidManifest
, the version 6.1.0 allow this also for foreground notifications. Then you don’t need to specify the channel id in your backend. This should keep the compatibility with old versions.Has anyone found an actual solution to this? Have followed @Dallas62’s instructions, but still no notifications while app is in the foreground.
State of the repository This repository is not actively maintained. The main reason is time. The second one is probably the complexity of notifications on both iOS and Android. Since this project probably need a huge refactor to fix some issue or to implement new features. I think you should probably consider these alternatives: Notifee free since september or react-native-notifications.
Same issue, everything works fine, besides the fact that I can’t trigger onNotification if android app is in foreground, the rest works without issues
After digging for few hours I was finally able to trigger onNotification handler for Android if app is in foreground: add to AndroidManifest.xml
For all the “+1”. First of all, this is not message which help to debug this case. Secondly, you probably copy and paste the
AndroidManifest
which include a line to hide notification in foreground. Regards,https://github.com/zo0r/react-native-push-notification/blob/master/CHANGELOG.md#breaking-changes-1
https://github.com/zo0r/react-native-push-notification#channel-management-android