Pages

Monday, July 21, 2014

Check Google Cloud Messaging (GCM) Client for Android using Curl

This post deals with testing a GCM Client without implementing a formal backend server. It uses the unix command line tool curl to send messages to the devices registered with GCM. Please note that this is not an end-to-end tutorial on how to implement GCM in your apps. If you want more information on the topic, please refer to http://developer.android.com/google/gcm/index.html.
You can run the following script on terminal to send messages to your test device.
curl -X POST \
-H "Authorization: key= YOUR_AUTHORIZATION_KEY" \
-H "Content-Type: application/json" \
-d '{
"registration_ids": [
"YOUR_DEVICE_TOKEN"
],
"data": {
"message": "YOUR_MESSAGE"
}
}' \
https://android.googleapis.com/gcm/send

YOUR_AUTHORIZATION_KEY:



YOUR_DEVICE_TOKEN: Token received when the client device registers with GCM server.

YOUR_MESSAGE: Message to send.

Happy messaging!

No comments:

Post a Comment