FCM Android - null message identifier

I have implemented my subclass of FirebaseMessagingService and I am successfully receiving downstream messages in FirebaseMessagingService.onMessageReceived(RemoteMessage) . My problem is that RemoteMessage.getMessageId() always returns null . From what I understood, a message identifier is mandatory and should be automatically generated by the FCM server. In fact, calling https://fcm.googleapis.com/fcm/send returns the message id, I just can’t access it on the application side.

Is there something I am missing?

Here is my FCM messaging class:

 public class FcmMessagingService extends FirebaseMessagingService { private static final String TAG = "FcmMessagingService"; @Override public void onMessageReceived(RemoteMessage remoteMessage) { Logg.d(TAG, "Received message; id: " + remoteMessage.getMessageId()); Map<String, String> data = remoteMessage.getData(); Logg.d(TAG, "Data: " + data); String message = data.get("message"); /* ... */ } } 
+5
source share
1 answer

With the Firebase Android SDK 9.4, this problem was resolved

From the release note :

FIXED RemoteMessage#getMessageId() now returns the correct message identifier for received messages. Previously, it returned null .

An update to the com.google.firebase:firebase-messaging dependency on version 9.4.0 really 9.4.0 problem.


Update 2.07.2016: I was informed that this is really a bug, and the fix will be included in the next release.


It turns out we cannot get the message id on the application side. I asked for Firebase support for help, and here is what they told me:

When FCM successfully receives the request, it will try to deliver all the signed devices, FCM will return a response that includes the messageID to your server. You cannot directly receive a MessageID on your client side (Android device). MessageID is a parameter in the response payload.

As a workaround, I generate custom message identifiers on the server and passing them to the payload.

What RemoteMessage.getMessageId () really does remains a mystery.

+12
source

All Articles