Firebase Cloud Messaging - "success" and "failure" in response JSON
I use Firebase Cloud Messaging to deliver notifications to my Android client apps, each notification should be sent to a single device according to its registration token.
Each time I send a notification via https://fcm.googleapis.com/fcm/send, I receive a JSON response like this one:
{
"multicast_id": 108,
"success": 1,
"failure": 0,
"canonical_ids": 0,
"results": [
{ "message_id": "1:08" }
]
}
I find success
and failure
redundant - don't they mean the same thing? Should I check both of them to be sure everything is fine? Is it always true that success != failure
?
As described here :
success
- Required, number of messages that were processed without an error.
failure
- Required, number of messages that could not be processed.
You get : "success": 1, which means 1 message was processed successfully and "failure": 0, which means no error
total number of requests to FCM server = success + failure
Sum of success and failure makes up the total number of requests. In your case, when you're sending to one user only, it doesn't matter. But when you're sending to multiple users, you can get success and failure and sum them up to know how many requests were sent to FCM server.
Ref: https://firebase.google.com/docs/cloud-messaging/http-server-ref#interpret-downstream