firebase / firebase/firebase-admin-java

Handle invalid token responses in FCM

未关闭
#1,064 3 条评论 3 个 reaction 已指派 0 人 在 GitHub 查看
api: messaging type: feature request
主要语言
Java
星标
620
派生
305
平均合并
3 小时 23 分钟
30 天内合并 PR
1

描述

As per the [documentation](https://firebase.google.com/docs/cloud-messaging/manage-tokens#ensuring-registration-token-freshness) a token could be invalid if you have two error codes:

- UNREGISTERED (HTTP 404)
- INVALID_ARGUMENT (HTTP 400)

However INVALID_ARGUMENTS can be caused by other errors.

At the moment we receive the content below from the `IncomingHttpResponse` which is also the error message from the `FirebaseMessagingException`. What we do is to check the string of the message in order to delete these tokens.

```
Content: {
"error": {
"code": 400,
"message": "The registration token is not a valid FCM registration token",
"status": "INVALID_ARGUMENT",
"details": [
{
"@type": "type.googleapis.com/google.firebase.fcm.v1.FcmError",
"errorCode": "INVALID_ARGUMENT"
}
]
}
}
```

What is the proper way to handle these errors?
Does it make sense to update FirebaseMessagingException to provide more information about which field is invalid or perhaps have a new error code - INVALID_TOKEN? This would remove a lot of unambiguity as to when it is needed to manage the token.

贡献指南

打开贡献指南

调研方向

Start with the linked Firebase token-management documentation and trace how IncomingHttpResponse becomes a FirebaseMessagingException. Compare the UNREGISTERED and INVALID_ARGUMENT responses in the issue, then determine how completion should distinguish invalid registration tokens from other INVALID_ARGUMENT failures without relying on message strings.

由索引模型根据 Issue 内容生成。

评估

技术栈
java
领域
backend-api-design
Issue 类型
功能
难度
5/5
预计耗时
一周以上
活跃度
停滞
描述清晰度
需要澄清
新手友好度
30/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。