Can I use POSTMAN client on Google Chrome to send payload message to GCM server for testing purpose. Secondly if yes, what is the header and url parameter to be sent.
Yes, you can.
URL: https://android.googleapis.com/gcm/send
Headers:
Body (click on the 'raw' tab):
{
"collapse_key": "score_update",
"time_to_live": 108,
"delay_while_idle": true,
"data": {
"score": "4x8",
"time": "15:16.2342"
},
"registration_ids":["4", "8", "15", "16", "23", "42"]
}
Note: registration_ids
is the only required field, all the others are optional.
URL: https://android.googleapis.com/gcm/send
Headers:
Body (click on the 'x-www-form-urlencoded' tab):
collapse_key=score_update
time_to_live=108
delay_while_idle=1
data.score=4x8
data.time=15:16.2342
registration_id=42
Note: registration_id
is the only required field, all the others are optional.
Source: https://developer.android.com/google/gcm/http.html
Just for the record and to complete the nice answer from @Alexandru Rosianu the GCM endpoint changed a while ago and it is suggested to use the new one. Here is an example taken from the official docs:
To send a message, the application server issues a POST request. For example:
https://gcm-http.googleapis.com/gcm/send
A message request is made of 2 parts: HTTP header and HTTP body.
The HTTP header must contain the following headers:
Authorization
: key=YOUR_API_KEY Content-Type
: application/json
for JSON; application/x-www-form-urlencoded;charset=UTF-8
for plain text. If Content-Type
is omitted, the format is assumed to be plain text.For example:
Content-Type:application/json
Authorization:key=YOUR_API_KEY
{
"notification": {
"title": "Portugal vs. Denmark",
"text": "5 to 1"
},
"to" : "bk3RNwTe3H0:CI2k_H..."
}
The HTTP body content depends on whether you're using JSON or plain text. See the Server Reference for a list of all the parameters your JSON or plain text message can contain.
Example using Curl:
# curl --header "Authorization: key=YOUR_API_KEY" \
--header Content-Type:"application/json" \
https://gcm-http.googleapis.com/gcm/send \
-d "{\"notification\": { \"title\": \"Portugal vs. Denmark\"," \
"\"text\": \"5 to 1\" }, \"to\" : \"bk3RNwTe3H0:CI2k_H...\" }"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With