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.

Clicking the notification with the app in foreground has data missing

See original GitHub issue

@evollu
I’ve been working on getting the on click working properly for my notifications, currently focusing on android. I have the on click for killed, and background working great but I’m having trouble when the app is in the foreground. When the notification is first received, all the data I need is there but when I click on it all the data I need for my on click function is stripped out. Is there a solution for this?

Console log for when notification is received: notif_received

Console log for when that same notification is clicked: notif_clicked

My payload is:

           body = {
                "to": this.chat.token,
                "content_available": true,
                "priority": "high",
                //"click_action": "fcm.ACTION.OPEN_NOTIFICATION",
                "data": {
                    "senderUid": this.user.uid,
                    "chatDocId": this.chat.docId,
                    "messageDocId": messageDoc.id,
                    "show_in_foreground": true,
                    "companyName": this.chat.users[`${this.user.uid}`].companyName,
                    "groupChat": this.chat.groupChat,
                    "color":"#a7ffeb",
                    "priority":"high",
                    "id": this.chat.docId,
                    "show_in_foreground": true,
                    "sound": "default",
                    "click_action": "fcm.ACTION.HELLO",
                    "vibrate": 300,
                    "lights": true,
                    "senderUid": this.user.uid,
                    "chatDocId": this.chat.docId,
                    "messageDocId": messageDoc.id,
                    "body": messageText,
                    "title": this.user.displayName,
                    "icon": "notification_icon",
                },
                notification: {
                    "body": messageText,
                    "title": this.user.displayName,
                    "click_action": "fcm.ACTION.HELLO",
                    "sound": "default",
                    "vibrate": 300,
                    "lights": true,
                }

So to be clear the the important data that is missing is

                    "senderUid": this.user.uid,
                    "chatDocId": this.chat.docId,
                    "messageDocId": messageDoc.id,
                    "companyName": this.chat.users[`${this.user.uid}`].companyName,
  1. What version of RN and react-native-fcm are you running? “react-native”: “^0.49.3”, “react-native-fcm”: “^12.0.0”,

  2. What device are you using? (e.g iOS9 emulator, Android 6 device)? Android

  3. Is your app running in foreground, background or not running? foreground

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:11 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
sahil290791commented, Mar 9, 2018

@rtman got it searched in settings, it was inside some security settings, may be its different in Mi phones running 7.0 . Thanks a lot for the quick reply.

1reaction
rtmancommented, Mar 9, 2018

@sahil290791

You have to enable AutoStart in Settings > Installed Apps > Your App Name > Autostart.

Really annoying that xiaomi does this.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Firebase onMessageReceived not called when app in ...
The function onMessageReceived() in FirebaseMessagingService() class gets triggered regardless of app being in background or foreground and we will have to ...
Read more >
Why my push notifications are not being received?
Now the user simply swiped it out. Basically cleared/deleted from notifications. And our application has no way to get that lost data.
Read more >
Notifications Not Shown - Mobile Push
Settings > Alert slider to make sure it's set up the way you want. Look in Settings > Apps and check the Notifications...
Read more >
didReceiveRemoteNotification not c… - Apple Developer
If the app is in the foreground or using an iOS 12 device the method is called. I register for push notification in...
Read more >
Receive messages in a JavaScript client - Firebase - Google
When your app is in the foreground (the user is currently viewing your web page), you can receive data and notification payloads directly...
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