FCM HTTP V1 API返回404错误,表示未注册的令牌。

25

FCM HTTP v1 API本应在设备注销(应用卸载)时返回错误代码“UNREGISTERED”。然而,API返回404“请求的实体未找到”。

有人遇到过这种情况吗?这是否是预期行为?文档中没有任何提及。

当收到包含消息“Requested entity was not found”的404错误时,可以安全地假定设备已注销吗?

以下是收到的完整错误消息正文。

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

异常:

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

2个回答

21

是的,我在firebase-admin-node模块中遇到过这个问题,最近已经更新了,将NOT_FOUND映射到"未注册"错误,因此看起来这是一个预期的响应。

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

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

您可能需要确认不同浏览器/设备中的未注册令牌。即,我认为来自chrome的未注册令牌与来自firefox的返回不同的错误。


1
我们在通过旧版 FCM 端点向未注册设备发送通知时,会遇到错误码 404。
https://fcm.googleapis.com/fcm/send

API v1的文档已更新,不再包含此错误代码。

在API v1中,我遇到了相同的错误,{ "error": { "status": "NOT_FOUND", "message": "请求的实体未找到。", "code": 404, "details": [ { "errorCode": "UNREGISTERED", "@type": "type.googleapis.com/google.firebase.fcm.v1.FcmError" } ] } } - Mehul

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接