Notification popup not showing when app at background - Android
See original GitHub issueBug
Remote notification doesn’t pop up on Android when app is in background. I did receive the notification at onNotification though. Side note: Notification pop up was working back in version 3.2.1. At that time, both notifications from firebase console and my own api will trigger onNotification and show popup. However with the current version, using firebase console will show the notification in notification tray but doesn’t popup nor trigger onNotification while using my api will trigger onNotification but does not show popup.
Environment info
react-native info
output:
System:
OS: macOS Mojave 10.14.6
CPU: (4) x64 Intel(R) Core(TM) i5-3210M CPU @ 2.50GHz
Memory: 39.16 MB / 8.00 GB
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 13.7.0 - /usr/local/bin/node
Yarn: 1.17.0 - /usr/local/bin/yarn
npm: 6.14.2 - /usr/local/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
SDKs:
iOS SDK:
Platforms: iOS 13.2, DriverKit 19.0, macOS 10.15, tvOS 13.2, watchOS 6.1
Android SDK:
Android NDK: 20.0.5594570
IDEs:
Android Studio: 3.5 AI-191.8026.42.35.6010548
Xcode: 11.3.1/11C504 - /usr/bin/xcodebuild
npmPackages:
@react-native-community/cli: ^2.9.0 => 2.10.0
react: 16.9.0 => 16.9.0
react-native: 0.61.5 => 0.61.5
npmGlobalPackages:
react-native-cli: 2.0.1
Library version: 3.4.0
Steps To Reproduce
- Install & setup react-native-push-notification
- Use Firebase console to send test message = Notification popup showed but onNotification not triggered
- Use own api to send notification = Notification popup not showed but onNotification triggered
Describe what you expected to happen:
- Notification pop up when app is in background/exit
Reproducible sample code
- npm i --save react-native-push-notification@3.4.0
- Set up androidmanifest.xml and gradle file as per instruction
- Set up code as follow:
PushNotification.configure({
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 here
// required on iOS only
notification.finish(PushNotificationIOS.FetchResult.NoData);
},
// Android only
senderID: "XXXXXX", //This is hidden to protect my own project
// iOS only
permissions: {
alert: true,
badge: true,
sound: true
},
popInitialNotification: true,
requestPermissions: true
})
Issue Analytics
- State:
- Created 3 years ago
- Reactions:3
- Comments:16
Top Results From Across the Web
Android Notifications Not Showing Up? 10 Fixes You Can Try
Not seeing notifications show up on your Android phone? Try these fixes to get Android notifications working again.
Read more >How to Fix Notifications Not Showing up on Android - Lifewire
Cause of Notifications Not Showing up on Android · Do Not Disturb or Airplane Mode is on. · Either system or app notifications...
Read more >FCM notification doesn't show notification pop up in background
Heads up notifications are used in app and I do get the notification but notification doesn't pop up as it do while app...
Read more >Notifications Not Shown - Mobile Push
Android Settings App > Notifications > Your App you should see "Show notifications" enable and all categories underneath enabled.
Read more >How exactly do apps not running "in the background" receive ...
Well that's not correct. Since Android 8 apps cannot run background services. They either need to run a foreground service (with persistent ...
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
And what is the message send from server-side:
@muriloneo having same issue notification sounds and pops up when app in foreground but when app closed or background notification silently show icon on notification tray (or area where notification icon show). how to implement same function for all states like social media messenger do. @Dallas62 if you have solution kindly spare some kind time