Notifications received but not showing userInteraction and data when app is in background on Android. IOS works fine
See original GitHub issueQuestion
I am able to receive the notifications for both Android and IOS and I am trying to navigate the user to screens according to the type of notification when the user taps on the notification. IOS works fine but on Android when I receive the notification in foreground then onNotification properly gets called and I receive this
{
foreground: true
id: "*******"
message: "[add your message]"
title: "Working Good"
type: "customType"
userInteraction: false
}
which has userInteraction which I use to determine user clicked on notification.
PROBLEM The issue is when the app is in background onNotification does not get called and when the app is killed onNotification gets called but is receive
{
collapse_key: "com.project"
finish: ƒ finish()
foreground: false
from: "*********"
google.delivered_priority: "high"
google.message_id: "0:10009434*****"
google.original_priority: "high"
google.sent_time: 159544444361
google.ttl: 2234200
type: "customType"
}
which does not have userInteraction property. Please help.
Push notification version: ^3.1.9 React native version: 0.61.5
Issue Analytics
- State:
- Created 3 years ago
- Comments:6
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 receive iOS notifications in background without user ...
Launching your app in the background gives you time to process the notification and download any data associated with it, minimizing the ...
Read more >Restrictions on starting activities from the background
From this screen, the user can control their notification preferences. Exceptions to the restriction. Apps running on Android 10 or higher can start...
Read more >Notifications Not Shown - Mobile Push
Android,iOS: In your Device Settings > Notifications > Your App, you can turn on and off push notifications. Make sure push permissions are...
Read more >Firebase Push notifications in React Native Apps - Enappd
Works natively in iOS. Uses the ShortcutBadger on Android, and as such will not work on all Android devices. Sending Notification Data From...
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 FreeTop 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
Top GitHub Comments
hello friend, well i was guided by a code i found on the net and i analyzed the way the notifications were received and i applied this form and it worked
APP IS OPEN: (Visible to the user, not minimized) If the app is open it recives the data in the object data{}, it recives the object userInteraction but in false, when the user touches the notification userInteraction goes to true
APP IS CLOSED: (minimized or closed) when the app is closed, you receive the notification, and touching the notification opens the app and you receive the data without the data object and also without the userInteraction object, I simply validate it with the object infodata.foreground == false, if you receive the notification and open the app through the executable, open it normally without redirection, then when you click on the notification it sends you to the page you indicate
@luigbren Thank you so much for your answer. I tried as you said and now working well in foreground, background and app closed state. Previously, i used different JSON format of remote message i.e
{ "data": { "title": "Hello John Doe", "message": "How are you? How you doing?" }, "to": "/topics/fcmDemo" }
I changed this format to :
{ "notification": { "title": "Hello John Doe", "body": "How are you? How you doing?" }, "data": { "badge": 35, "payload": { "message": "This is payload message", "url": "This is payload url" } }, "to": "/topics/fcmDemo" }
I am able to get FCM notification form FCM console and remote message using https://fcm.googleapis.com/fcm/send.
Next , I will try to route as you said using payload data.
Thank you again to all of you.