Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sending Push via Postman using Firebase Messaging

I'm trying to use Postman to send a single Push Notification using Firebase Cloud Messaging service.

This is a working cURL command for the same purposal, on which I'm using as a reference.

curl -X POST --header "Authorization: key=<API_ACCESS_KEY>" --Header "Content-Type: application/json" https://fcm.googleapis.com/fcm/send -d "{\"to\":\"<YOUR_DEVICE_ID_TOKEN>\",\"notification\":{\"body\":\"Firebase\"} \"priority":\"10"}" 

What I have done so far..

1 - Set the Headers appropriately

enter image description here

2- At Body , I'm using raw

{     "to" : "<YOUR_DEVICE_ID_TOKEN>"     ,       "notification": {     "body": "Firebase Cloud Message"   }    } 

When executing, I'm getting back 401 - Unauthorized.

What's missing to correctly send the push notification?

like image 635
Machado Avatar asked Aug 08 '16 16:08

Machado


People also ask

Can you send push notifications with Firebase?

You can send messages via the Firebase Admin SDK or the FCM server protocols. You can use the Notifications composer for testing and to send marketing or engagement messages using powerful built-in targeting and analytics or custom imported segments.


2 Answers

The correct way to set up Authorization key at Header is

key=<API_ACCESS_KEY>

and not only

<API_ACCESS_KEY>

Silly mistake, but since this could be useful for someone for testing Firebase Messaging with Postman I'm leaving the question opened.

like image 187
Machado Avatar answered Sep 19 '22 22:09

Machado


Posting FCM through POSTMAN

Body - to is token id (should be generated through instance token) write body in raw binary application/json body tye

{    "to": "cpa8cZPjq-w:APA91bF122f1Rnhu9v47bL    YMajaNTHAIU5SzItDwTy9o2MCIveG0PlK78VPvp3d    CqjwnUKZ4    ngi1trSyM3_aXttW62iknFfbPGtjRLhZr6wq-3qFdboz8gzdOGPz**********",     "notification": {      "body": "Hello",     "title": "This is test message."    }    } 

header: should have authorization :server key

Content type : application/json headerimage after posting here the success message: success message image

like image 25
praveen dewangan Avatar answered Sep 22 '22 22:09

praveen dewangan