Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle invalid token responses in FCM #1064

Open
yanikapitanov opened this issue Jan 24, 2025 · 1 comment
Open

Handle invalid token responses in FCM #1064

yanikapitanov opened this issue Jan 24, 2025 · 1 comment

Comments

@yanikapitanov
Copy link
Contributor

As per the documentation 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.

@google-oss-bot
Copy link

I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants