how to fix 'InvalidRegistration' FCM

7.1k Views Asked by At

I'm getting the InvalidRegistration error in response of my post request for sending push notification.

When I use the Firebase console to send push notification it works all fine. so I copy the exact registration token I've used in console. I also get my api-key from my project-settings/cloud-messaging. for sending the post request I've used postman. I've sent my post request to https://fcm.googleapis.com/fcm/send

my postman header has this attributes:

key: Authorization value: key=<api-key-i-got-from-console>
key: Content-Type value: application/json

my body is:

{
 "to" : "fDj8iG5ajZI:APA91bHfs_AjdxOc5Qn-1Plr_OfitrdCTchb4syhPGC0DhPMGiWggJ9mQ5W00ombqowlUSCUOfH_0N3KA-KF0VjQvj5mcMNUMUBgTblpsNzra60kwrbtH2ikfdBa8lenh__olBpGZD4O'",
 "collapse_key" : "type_a",
 "notification" : {
     "body" : "plz work",
     "title": "title"
 },
}

I get this response from the Firebase

{
    "multicast_id": 5801302802423881516,
    "success": 0,
    "failure": 1,
    "canonical_ids": 0,
    "results": [
        {
            "error": "InvalidRegistration"
        }
    ]
}

I did the same with fcm and django-push-notification and got the same result I have no clue what am I doing wrong since my token works with the console and I can send push notifications from the console.

1

There are 1 best solutions below

0
On

it was my bad that I had an extra ' in the end of my token...