Testing FCM Push Notification

Testing FCM Push Notification through Postman/Terminal — Part 1

Tutorial to test Firebase Cloud Messaging (FCM) Push Notification through Postman or Terminal (curl command)

Firebase Cloud Messaging (FCM) + Postman / Terminal → Send Push Notification

Methods to test FCM Push Notifications:

Notifications composer

Notification composer
Send test message to a registered token (device)

Legacy FCM HTTP Protocol + Postman/Terminal

Copy <Server Key>

Add the following details in the Postman :-

POSTMAN — Add Endpoint, Headers and Method type

☛ Send Notification message (Generic)

{
"to" : "FCM_TOKEN_OR_TOPIC_WILL_BE_HERE",
"notification" : {
"body" : "Body of Your Notification",
"title": "Title of Your Notification"
}
}
Sending Notification Message (Generic) using POSTMAN
curl --location --request POST 'https://fcm.googleapis.com/fcm/send' \
--header 'Authorization: key=< Server Key >' \
--header 'Content-Type: application/json' \
--data-raw '{
"to" : "FCM_TOKEN_OR_TOPIC_WILL_BE_HERE",
"notification" : {
"body" : "Body of Your Notification",
"title": "Title of Your Notification"
}
}'

☛ Send Data message (Custom) :

{
"to" : "FCM_TOKEN_OR_TOPIC_WILL_BE_HERE",
"data" : {
"body" : "Body of Your Notification in Data",
"title": "Title of Your Notification in Title",
"key_1" : "Value for key_1",
"key_2" : "Value for key_2"
}
}
Sending Data Message (Generic) using POSTMAN
curl --location --request POST 'https://fcm.googleapis.com/fcm/send' \
--header 'Authorization: key=< Server Key >' \
--header 'Content-Type: application/json' \
--data-raw '{
"to" : "FCM_TOKEN_OR_TOPIC_WILL_BE_HERE",
"data" : {
"body" : "Body of Your Notification in Data",
"title": "Title of Your Notification in Title",
"key_1" : "Value for key_1",
"key_2" : "Value for key_2"
}
}'

Explanation of Body payload:

Consultant at GlobalLogic | iOS app developer | AWS Certified Solutions Architect - Associate