Send data from your server to your users' devices, and receive messages from devices on the same connection. The GCM service handles all aspects of queueing of messages and delivery to client applications running on target devices, and it is completely free.
Distribute messages to your client app in any of three ways — to single devices, to groups of devices, or to devices subscribed to topics.
For purposes such as alerting users, chat messaging or kicking off background processing before the user opens the client app, GCM provides a reliable and battery-efficient connection between your server and devices.
Send acknowledgments, chats, and other messages from devices back to your server over GCM’s reliable and battery-efficient connection channel.
Send a message using GCM HTTP connection server protocol:
https://gcm-http.googleapis.com/gcm/send Content-Type:application/json Authorization:key=AIzaSyZ-1u...0GBYzPu7Udno5aA { "to": "/topics/foo-bar", "data": { "message": "This is a GCM Topic Message!", } }
Handle a downstream message on an Android device:
@Override public void onMessageReceived(String from, Bundle data) { String message = data.getString("message"); Log.d(TAG, "From: " + from); Log.d(TAG, "Message: " + message); // Handle received message here. }