question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Firebase Messaging returning "Invalid registration token" when sending silent APNs notification

See original GitHub issue

[REQUIRED] Step 2: Describe your environment

  • Operating System version: MacOS Big Sur
  • Firebase SDK version: 9.6.0 (Firebase Admin version)
  • Firebase Product: messaging
  • Node.js version: 12
  • NPM version: 6.14.12

[REQUIRED] Step 3: Describe the problem

FCM started responding with INVALID_ARGUMENT with a description of Invalid registration token to any calls for sending APNs silent notifications. We’ve verified that the tokens are actually valid. This happens in the node client, and also when calling directly the HTTP v1 send endpoint.

We started noticing this behavior roughly on 2021-04-08 14:30:00 ET, which suspiciously coincides with a deploy of our production functions. Note that this deploy didn’t include any updates to the relevant codepaths nor libraries involved.

We also found someone with the very same problem on Stack Overflow: https://stackoverflow.com/questions/67051941/fcm-throwing-invalid-argument-for-ios-notifications

Steps to reproduce:

Call the HTTP v1 send endpoint:

POST https://fcm.googleapis.com/v1/{parent=projects/*}/messages:send

with the following payload:

{
  "validate_only": false,
  "message": {
    "token": <FCM TOKEN>,
    "apns": {
        "payload": {
            "aps": {
              "content-available": 1
            }
        }
    }
  }
}

with a valid FCM token and you should receive the following response:

{
    "error": {
        "code": 400,
        "message": "Request contains an invalid argument.",
        "status": "INVALID_ARGUMENT",
        "details": [
            {
                "@type": "type.googleapis.com/google.firebase.fcm.v1.FcmError",
                "errorCode": "INVALID_ARGUMENT"
            },
            {
                "@type": "type.googleapis.com/google.rpc.BadRequest",
                "fieldViolations": [
                    {
                        "field": "message.token",
                        "description": "Invalid registration token"
                    }
                ]
            }
        ]
    }
}

But if you replace content-available with badge, the notification is sent correctly:

{
    "name": "projects/<PROJECT_ID>/messages/<MESSAGE_ID>"
}

We’ve also tried sending content_available and contentAvailable as keys, and true as value, to no avail.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:19
  • Comments:15 (1 by maintainers)

github_iconTop GitHub Comments

11reactions
chong-shaocommented, Apr 15, 2021

Latest update: FCM backend performed a fast rollback today. The backend should be at the good version without this issue now.

8reactions
hiranya911commented, Apr 13, 2021

This has been forwarded to the FCM backend team. They are looking into it. We’ll post an update when new information is available.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Best practices for FCM registration token management
On this page · Basic best practices. Retrieve and store registration tokens; Detect invalid token responses from the FCM backend · Ensuring registration...
Read more >
Invalid registration token provided. Make sure it matches the ...
One of the interesting reasons for invalid registration is: that device have a different token. Maybe you are trying to use a past...
Read more >
invalid registration token provided. make sure it ... - You.com
Make sure it matches the registration token the client app receives from registering with Firebase Notifications. Do not truncate or add additional characters....
Read more >
Cloud Messaging | FlutterFire
Messaging currently only supports usage with the default Firebase App instance. ... use the returned token to send messages to users from your...
Read more >
Push Notification Troubleshooting for Android - Braze
Users have uninstalled the application. This will invalidate their FCM push token. Invalid Firebase Cloud Messaging server key. The Firebase Cloud Messaging ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found