wiki:GCM

Table of Contents

  1. Overview
  2. Integration
  3. Test

Overview

Google Cloud Messaging for Android (GCM) is a free service that helps developers send data from servers to their Android applications on Android devices, and upstream messages from the user's device back to the cloud.

Integration

  1. enables GCM and obtaining API Key: http://developer.android.com/google/gcm/gs.html
  2. makes the client app to obtain and submit the Reg ID: http://developer.android.com/google/gcm/client.html
  3. implements your GCM Server: http://developer.android.com/google/gcm/server.html

Test

You can manually sending a GCM push by command line to a specified client if you have gotten the API Key and a Reg ID of your app on one provided device:

# fill the API Kye and Reg ID, and set the JSON string according to your need
api_key="xx...xxx"
reg_id="yy...yy"
curl --header "Authorization: key=$api_key" --header Content-Type:"application/json" https://android.googleapis.com/gcm/send  -d "{\"registration_ids\":[\"$reg_id\"],\"data\":{\"code\":123}}"
# useless stub line
Last modified 4 years ago Last modified on Apr 1, 2014, 11:06:00 AM