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.

貢獻指南

開啟貢獻指南

研究方向

從連結的 Firebase token 管理文件開始,追蹤 IncomingHttpResponse 如何變成 FirebaseMessagingException。比較 issue 中的 UNREGISTERED 和 INVALID_ARGUMENT 回應,然後判斷實作應如何在不依賴訊息字串的情況下,區分無效的註冊 token 與其他 INVALID_ARGUMENT 錯誤。

由索引模型根據 Issue 內容生成。

評估

技術堆疊
java
領域
backend-api-design
Issue 類型
功能
難度
5/5
預估耗時
一週以上
活躍度
停滯
描述清晰度
需要釐清
新手友好度
30/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。