当设备未注册(应用程序卸载)时,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/