Notification pop up doesn't show onNotification triggered for remote notifications
See original GitHub issueBug
Remote notification doesn’t pop up on Android when app is in background/killed.onNotification method triggered though. Side note: Notification pop up was working back in version 3.1.3 but now i have upgraded the RN version so it stops working.
Environment info
react-native info
output:
OS: macOS Mojave 10.14.6 CPU: (4) x64 Intel® Core™ i5-5257U CPU @ 2.70GHz Memory: 56.25 MB / 8.00 GB Shell: 3.2.57 - /bin/bash Binaries: Node: 12.9.1 - /usr/local/bin/node Yarn: Not Found npm: 6.11.3 - /usr/local/bin/npm Watchman: 4.9.0 - /usr/local/bin/watchman Managers: CocoaPods: 1.7.5 - /usr/local/bin/pod SDKs: iOS SDK: Platforms: iOS 13.2, DriverKit 19.0, macOS 10.15, tvOS 13.2, watchOS 6.1 Android SDK: API Levels: 23, 27, 28, 29 Build Tools: 28.0.3, 29.0.2 System Images: android-29 | Google APIs Intel x86 Atom Android NDK: Not Found IDEs: Android Studio: 3.5 AI-191.8026.42.35.6010548 Xcode: 11.2.1/11B500 - /usr/bin/xcodebuild Languages: Java: 1.8.0_222 - /usr/bin/javac Python: 2.7.16 - /usr/bin/python npmPackages: @react-native-community/cli: Not Found react: 16.11.0 => 16.11.0 react-native: 0.62.2 => 0.62.2
Library version: 4.0.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:
1.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); // 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
- Comments:26
Top GitHub Comments
facing same issue… notification appears on the notification tray but popup doesn’t show.
Ho! Didn’t notice, the payload you send is not the payload that should be send in this case. You send data but you should send a notification. Two solutions:
data
tonotification
notification.data
whenonNotification
is triggered.