FCM HTTP V1 API返回404,以获取未注册的令牌 [英] FCM HTTP V1 API returns 404 for unregistered token

查看:640
本文介绍了FCM HTTP V1 API返回404,以获取未注册的令牌的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

FCM HTTP v1 API应该在设备未注册(应用程序已卸载)时返回错误代码"UNlocated".但是API返回404找不到请求的实体".

FCM HTTP v1 API supposed to return error code "UNREGISTERED" when device is unregistered (app uninstalled). However API returns 404 "Requested entity was not found".

有人经历过吗?这是预期的吗?在文档的任何地方都没有提及此内容.

Have anyone experienced this? Is this the expected one? There is no mention about this anywhere in the documentation.

是否可以安全地假设收到404错误消息找不到请求的实体"时取消注册设备?

Is it safe to assume device is unregistered when 404 error with the message "Requested entity was not found" received?

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

Following is the full body of the error received.

{
  "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

推荐答案

是的,我在firebase-admin-node模块中遇到了这种情况,该模块最近已更新为将NOT_FOUND映射为未注册"错误,因此它看来这是预期的反应.

Yes, I've experienced this with the firebase-admin-node module, which has been updated recently to map NOT_FOUND to an "unregistered" error, so it appears that it is an expected response.

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

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

(Though it looks to be the status being NOT_FOUND is the key info rather than the "Requested entity was not found" message)

您可能要确认的一件事是来自不同浏览器/设备的未注册令牌.也就是说,我认为chrome中未注册的令牌返回的错误与firefox中返回的错误不同.

One thing you may want to confirm is unregistered tokens from different browsers/devices. I.e., I think unregistered tokens from chrome returned a different error than one from firefox.

这篇关于FCM HTTP V1 API返回404,以获取未注册的令牌的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆