evollu / react-native-fcm

react native module for firebase cloud messaging and local notification
MIT License
1.73k stars 682 forks source link

No data delivered with `custom_notification` #584

Open haggholm opened 6 years ago

haggholm commented 6 years ago

react-native@0.48.4 react-native-fcm@9.7.0

Our app works fine with ordinary GCM notifications, but I wanted to use the custom_notification feature in order to run some logic on receiving background messages. However, when the app ‘wakes up’ on clicking either the library’s generated notification, or a manually created local notification via FCM.presentLocalNotification(), the notification that arrives through FCM.getInitialNotification() contains no data: only the flag opened_from_drawer and an empty fcm: {}. I’ve previously seen that when I had misconfigured the Android manifest and the intent matching the click_action was not associated with the main activity; but as mentioned above, it’s now working fine with regular GCM notifications.

evollu commented 6 years ago

can you check FCM.on('notification' callback? if app is in background, it might be possible that the notification goes there

haggholm commented 6 years ago

The notification callback gets the proper events when the GCM message is sent, but when the app is opened, there are no data. I suppose I could cache the results of the last received GCM notification, but then how do I tell what notification was clicked to open the app?

Or maybe I misunderstand?

evollu commented 6 years ago

did you send custom_notification together with notification payload?

vlaraort commented 6 years ago

Did you fixed this? I have the same problem

haggholm commented 6 years ago

@evollu No, I was sending only custom_notification for Android devices (as I believe the documentation directs).

(Apologies for late answer, I had moved onto other things and missed the notification.)

evollu commented 6 years ago

can you post your payload here?