0
votes

I have created my App in Firebase and configured for cloud messaging. When I am sending the notification from Firebase Console, device gets the notification but if I try to send via Rest API (Using PostMan). Then notification not coming to device but the response is showing as Success.

Here is my PostMan request

URI - https://fcm.googleapis.com/fcm/send

Header: Content-Type:application/json Authorization:key=MY_SERVER_KEY

Body: { "data": { "title": "Firebase", "detail": "I am firebase" }, "to" : "MY FCM TOKEN HERE" }

Response : { "multicast_id": 7834540847388366233, "success": 1, "failure": 0, "canonical_ids": 0, "results": [ { "message_id": "0:1532422122326299%ebf5f25ef9fd7ecd" } ] }

I have searched and it seems the way mentioned in documentation is same as I am following Can anyone let me know why it is not working? Thanks

1
you need to use "notification" key instead if "data"rv7284
@rv7284, Thank you. It worked..Janmenjaya

1 Answers

3
votes

I am posting here so as to guide others. As per the guidance of @rv7284, We need to send the data in notification key rather any other key.

So While requesting the body should look like this, Other request parameter like header and all will be same as mentioned in the question.

{ "notification": {
 "title": "Firebase",
 "detail": "I am firebase"
},
 "to" : "YOUR FCM TOKEN"
}