firebase / firebase/firebase-admin-java

Handle invalid token responses in FCM

Offen
#1,064 3 Kommentare 3 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
api: messaging type: feature request
Vorherrschende Sprache
Java
Sterne
620
Forks
305
Ø Merge
3 Std. 23 Min.
Gemergte PRs (30 T.)
1

Beschreibung

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.

Beitragsleitfaden

Beitragsleitfaden öffnen

Rechercherichtung

Beginne mit der verlinkten Dokumentation zur Verwaltung von Firebase-Tokens und verfolge, wie aus IncomingHttpResponse eine FirebaseMessagingException wird. Vergleiche die Antworten UNREGISTERED und INVALID_ARGUMENT im Issue und ermittle anschließend, wie die Implementierung ungültige Registrierungstokens von anderen INVALID_ARGUMENT-Fehlern unterscheiden sollte, ohne sich auf Nachrichtenzeichenfolgen zu stützen.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
java
Bereich
backend-api-design
Issue-Typ
Feature
Schwierigkeit
5/5
Geschätzter Aufwand
Über eine Woche
Aktivitätsstatus
Veraltet
Klarheit
Muss geklärt werden
Anfängerfreundlichkeit
30/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.