google-cloud-messaging - FCM HTTP V1 API 为未注册的 token 返回 404

标签 google-cloud-messaging firebase-cloud-messaging

当设备未注册(应用程序卸载)时,FCM HTTP v1 API 应该返回错误代码“未注册”。但是 API 返回 404“未找到请求的实体”。

有没有人经历过这个?这是预期的吗?文档中的任何地方都没有提到这一点。

当收到消息“未找到请求的实体”的 404 错误时,假设设备未注册是否安全?

以下是收到的错误的全文。

{
  "error": {
    "code": 404,
    "message": "Requested entity was not found.",
    "errors": [
      {
        "message": "Requested entity was not found.",
        "domain": "global",
        "reason": "notFound"
      }
    ],
    "status": "NOT_FOUND"
  }
}

异常(exception):
Caused by: com.google.firebase.messaging.FirebaseMessagingException: Requested entity was not found.
    at com.google.firebase.messaging.FirebaseMessaging.handleSendHttpError(FirebaseMessaging.java:266) ~[firebase-admin-5.9.0.jar:?]

引用 API 文档:

https://firebase.google.com/docs/reference/fcm/rest/v1/projects.messages
https://firebase.google.com/docs/reference/fcm/rest/v1/ErrorCode

最佳答案

是的,我在 firebase-admin-node 模块中遇到过这种情况,该模块最近已更新为将 NOT_FOUND 映射到“未注册”错误,因此这似乎是预期的响应。

https://github.com/firebase/firebase-admin-node/commit/069c9cd50502b0fa7cc6843ea3ef9d8d85dca9b9#diff-ce3edf3ab3ed8957259b6bd4035a0256R617

(虽然看起来状态为 NOT_FOUND 是关键信息,而不是“未找到请求的实体”消息)

您可能要确认的一件事是来自不同浏览器/设备的未注册 token 。即,我认为来自 chrome 的未注册 token 返回的错误与来自 firefox 的错误不同。

关于google-cloud-messaging - FCM HTTP V1 API 为未注册的 token 返回 404,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48928972/

相关文章:

ios - Firebase 云消息传递中是否有适用于 iOS 的 ttl "time to live"的替代方案?

android - 从 Android 到 Android 的 Google Cloud Messaging 是否可行?

android - 从 GCM 2.0 迁移到 GCM 3.0 InstanceID API

firebase - 如何使用 Firebase Cloud Messaging 向所有设备发送通知

node.js - 应用程序关闭时我没有收到 FCM 推送通知。 Ionic 3 和 Angular

ios - FCM 成功,但设备未显示通知 iOS

laravel - 消息 : The notification permission was not granted and blocked instead

php - 为什么我无法在 Android 设备上接收来自 GCM 的消息

android - 重新安装 Android 应用程序后,该应用程序会收到针对旧安装的通知

Android Google - 云消息报告