My firbase RemoteMessage has a mBundle with 12 key value pairs, according to debugger, those field were filled .
But when I say: remoteMessage.getData();
the resulting ArrayMap Map<String, String>
has size 0 and thus no elements.
How can I access the Map of remoteMessage?
onMessageReceived is provided for most message types, with the following exceptions: Notification messages delivered when your app is in the background. In this case, the notification is delivered to the device's system tray. A user tap on a notification opens the app launcher by default.
Firebase Cloud Messaging Platform (formerly named as GCM) is a free mobile notification service by Google that enables (third-party) app developers to send notifications from GCM (Google Cloud Messaging) servers to their users.
To get notification data when your app in the background, you should add click_action inside notification payload. "Put that intent-filter on your manifest, inside application tag." you can't put intent-filter inside application tag. your JSON dows not show where the click_action key goes.
interface. The RemoteMessage interface describes an outgoing & incoming message from the remote FCM server.
I know this might be late but You can get the data from Notification Object in RemoteMessage
String title = remoteMessage.getNotification().getTitle();
String body = remoteMessage.getNotification().getBody();
hope this helps
I also encountered same problem.
And finally fixed this problem.
In my case, server side's sending FCM payload problem.
like this.
options = {
priority: 'high',
notification: {
title: "title",
body: "message",
url: "some_url",
image_url: "some_image_url"
}
And I updated like following,
options = {
priority: 'high',
notification: {
title: "title",
body: "message",
},
data: {
url: "some_url",
image_url: "some_image_url"
}
After that, I could get payload values by remoteMessage.getData()
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With