firebase / firebase/firebase-admin-java

Handle invalid token responses in FCM

Abierto
#1,064 3 comentarios 3 reacciones 0 asignados Ver en GitHub
api: messaging type: feature request
Lenguaje dominante
Java
Estrellas
620
Forks
305
Merge medio
3 h 23 min
PR fusionados (30 d)
1

Descripción

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.

Guía de contribución

Abrir la guía de contribución

Línea de trabajo

Comienza con la documentación enlazada sobre la gestión de tokens de Firebase y sigue cómo IncomingHttpResponse se convierte en una FirebaseMessagingException. Compara las respuestas UNREGISTERED e INVALID_ARGUMENT del issue y determina después cómo la implementación debería distinguir los tokens de registro no válidos de otros errores INVALID_ARGUMENT sin depender de las cadenas de mensaje.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
java
Área
backend-api-design
Tipo de issue
Nueva funcionalidad
Dificultad
5/5
Tiempo estimado
Más de una semana
Estado de actividad
Estancado
Claridad
Necesita aclaración
Aptitud para principiantes
30/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.