I'm using the https://fcm.googleapis.com/fcm/send
api to send a push notification. I keep getting this error when trying to send a push notification using Postman:
{
"multicast_id": 7660095333537950368,
"success": 0,
"failure": 1,
"canonical_ids": 0,
"results": [
{
"error": "MismatchSenderId"
}
]
}
I definitely have the right Cloud Messaging server key in the Header Authorization with the value key={{firebase server key}}
. I'm posting to https://fcm.googleapis.com/fcm/send
this 'raw' 'json' body:
{
"to" : "AAAAr4-T02k:APA91bHicpacJ2tyn_XGcfRX3BnhkJSmyzWp-the-rest-of-my-server-key",
"priority": "high",
"data" : {
"content": {
"id": 1,
"channelKey": "mass",
"title": "Huston! The eagle has landed!",
"body": "A small step for a man, but a giant leap to Flutter's community!"
}
}
}
I'm using Flutter. I have the google-services.json in the root of the 'app' folder inside of the 'android' folder.
I've seen in other posts people say to check to make sure your server key matches in the google-services.json file. I don't see a server key in the google-services.json file. I do see a project_number
that matches the sender_id
in my Firebase Cloud Messaging settings. Should the google-services.json file also have a server_key somewhere?
What am I doing wrong?
CodePudding user response:
In your message body "to" field is for device registration token, not server key, see Firebase Cloud Messaging HTTP protocol.
The value can be a device's registration token, a device group's notification key, or a single topic (prefixed with /topics/)