Firebase 云消息传递 - 响应 JSON 中的“成功”和“失败”

voj*_*jta 6 android json firebase firebase-cloud-messaging firebase-notifications

我使用 Firebase Cloud Messaging 向我的 Android 客户端应用程序发送通知,每个通知应根据其注册令牌发送到单个设备。

每次我通过https://fcm.googleapis.com/fcm/send发送通知时,我都会收到这样的 JSON 响应:

{
  "multicast_id": 108,
  "success": 1,
  "failure": 0,
  "canonical_ids": 0,
  "results": [
    { "message_id": "1:08" }
  ]
}
Run Code Online (Sandbox Code Playgroud)

我发现successfailure多余的 - 它们不是同一件事吗?我应该检查他们两个以确保一切正常吗?总是这样success != failure吗?

小智 10

如上所述这里

success - 必需,已处理且无错误的消息数。

failure - 必需,无法处理的消息数。

你得到:"success": 1,表示成功处理了1条消息,而"failure": 0,表示没有错误