Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Curl command for sending FCM message
curl -i -H 'Content-type: application/json' -H 'Authorization: key=<your_server_key>' -XPOST https://fcm.googleapis.com/fcm/send -d '{
"registration_ids":["registration_ids", "of the", "target", "devices as array"],
"notification": {
"title":"Title of your notification",
"body":"content of your notification"
},
"data": {
"key1" : "value1",
"key2" : "value2",
"key3" : 23.56565,
"key4" : true
}
}'
@alihaider1793

This comment has been minimized.

Copy link

@alihaider1793 alihaider1793 commented Nov 14, 2017

how can we access the data values in onMessageReceived method?

@GoltsevEugene

This comment has been minimized.

Copy link

@GoltsevEugene GoltsevEugene commented Dec 5, 2017

In onMessageReceived() call remoteMessage.getData() - you will get Map<String, String> with your values.
@drulabs - thanks for sharing your code!!

@abelcallejo

This comment has been minimized.

Copy link

@abelcallejo abelcallejo commented Apr 17, 2018

should the values of the your_server_key and registration_ids need to be escaped?

@tyoc213

This comment has been minimized.

Copy link

@tyoc213 tyoc213 commented Nov 6, 2018

should the values of the your_server_key and registration_ids need to be escaped?

No because of -d '{...}'

@Pitala

This comment has been minimized.

Copy link

@Pitala Pitala commented Sep 20, 2019

Is there a way of adding a custom image to the message?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.