Reputation: 2768
I created a Device Group in firebase Messaging - Documentation here and got back the notification_key
Now when I use that notification_key
to send messages using Firebase Console, they are sent and delivered to all registered devices.
But doing the same thing outside the console (for example in postman) does not work, I do however get a success message for all devices and zero failures but the devices never receive the message.
Response in Postman
{
"success": 7,
"failure": 0
}
My post request is the following
curl -X POST \
https://fcm.googleapis.com/fcm/send \
-H 'Authorization: key=***' \
-H 'Content-Type: application/json' \
-d '{
"to": "my_notification_key",
"data": {
"hello": "test !"
}
}'
I feel like I am missing something but as per provided documentation that all it should need to send a message
From Firebase Documentation
https://fcm.googleapis.com/fcm/send
Content-Type:application/json
Authorization:key=AIzaSyZ-1u...0GBYzPu7Udno5aA
{
"to": "aUniqueKey",
"data": {
"hello": "This is a Firebase Cloud Messaging Device Group Message!",
}
}
any idea what is going wrong here as I receive success message but the message is never delivered to the devices?
Upvotes: 2
Views: 3523
Reputation: 2768
I had to pass the notification
instead of just 'data' as following
"to" : "notification_key",
"notification" : {
"body" : "Body of Your Notification",
"title": "Title of Your Notification"
}
Hope this helps someone.
Upvotes: 7