question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Notification pop up doesn't show onNotification triggered for remote notifications

See original GitHub issue

Bug

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

  1. Install & setup react-native-push-notification
  2. Use Firebase console to send test message = Notification popup showed but onNotification not triggered
  3. 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

  1. npm i --save react-native-push-notification@3.4.0
  2. Set up androidmanifest.xml and gradle file as per instruction
  3. 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:closed
  • Created 3 years ago
  • Comments:26

github_iconTop GitHub Comments

13reactions
NightFox-06commented, Jan 20, 2021

facing same issue… notification appears on the notification tray but popup doesn’t show.

3reactions
Dallas62commented, Jul 8, 2020

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:

  • Change the payload of your server from data to notification
  • Trigger local notification with values inside notification.data when onNotification is triggered.
Read more comments on GitHub >

github_iconTop Results From Across the Web

Notifications Not Shown - Mobile Push
Common reasons why Mobile Push notifications are not showing on your device. ... "popping up" on the screen but still shows in the...
Read more >
Asking Permission to Use Notifications - Apple Developer
Request permission to display alerts, play sounds, or badge the app's icon in response to a notification. Overview. Local and remote notifications get...
Read more >
React Native Push Notifications not working in Android but ...
Here is the function that I'm calling to trigger the notification. function pushNotif(){ PushNotification.localNotification({ channelId: " ...
Read more >
Remote Notifications - Triggered by user or not - Unity Answers
When your app is in foreground, iOS doesn't show notification as a push notification banner. Your code needs to handle if you want...
Read more >
Notification runtime permission - Android Developers
If the user selects the don't allow option, your app can't send notifications unless it qualifies for an exemption. All notification channels are...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found