29

I am testing the Firebase JSON to check the delivery receipts of the notification sent to the news app. I can successfully send the message to the Android app without any issues and I receive the message on my Android app. However, I want to know how and where can I check if the notification was successfully delivered to the Android app?

How do I use the message_id and/or multicast_id that is given back to get the delivery status of the notification? I can't find working code examples of checking for delivery status with Firebase. Does anyone have working JSON code to query the delivery status of a Firebase message via the message_id and/or multicast_id or another way? The Firebase documentation does not give examples on how to do this (or maybe I missed the example).

Please see the Firebase JSON below used to send the notification to the Firebase news app. Anyone's help is highly appreciated.

In the header I set authorization key=firebase_server_key and content type is set to application/json

{
    "to" : "token received from firebase",
    "notification" : {
      "body" : "test",
      "title" : "Alert",
      "icon" : "myicon",
      "delivery_receipt_requested": true
    }
  }

Output from postman:

{"multicast_id":7845213569874521,"success":1,"failure":0,"canonical_ids":0,"results":[{"message_id":"0:4853214789631%31bd1c9631bd1c96"}]}
Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
  • 1
    Hi, you can check the status on the FCM Diagnostics page on the google play store page for your app. Enter the message id and it should show you the status. – FrankR Jan 17 '17 at 16:12
  • 1
    We want to do this via a remote application that will pull the status and hence we need a JSON example. – support ecommunicate Jan 17 '17 at 16:14
  • 2
    I don't think there is an API for this currently. You could reach out to google and see if they can confirm this. Also just FYI any messages sent via the FCM API or sent to topics won't appear in the console in Firebase. – FrankR Jan 17 '17 at 16:17

2 Answers2

8

Update:

The Diagnostics Tool has been removed since Nov. 30, 2017:

You can no longer access FCM diagnostics data in the Play Console.


Confirming what @user7410521 said in the comments section. There is currently no available API to make use of the message_ids/multicast_ids to retrieve the details of the delivery status of the message sent, other than using the FCM Diagnostics Page. Do also keep in mind that the Diagnostics page is only usable when the app is already published (for Alpha testing or later).

I noticed that you included the delivery_receipt_requested parameter in your payload. Receiving the a message confirmation should be enough to determine that the device received the message.

AL.
  • 36,815
  • 10
  • 142
  • 281
-2

Though there is no API so far also I could find out. I have tried a workarond. From the server side PHP I am sending an FCM message. Let me present how I have handled this in PHP.

$fcm_return = fcm_message_send($message);
$fcm_return_JSON = json_decode($fcm_return, true);
echo $$fcm_return_JSON['success'];

As I am sending a message to one device, I am comparing return with 1. Based on this you could further implement your logic.