From e5cefd1d523e1f41298595203b97a08064ed0ac0 Mon Sep 17 00:00:00 2001 From: Katie McCormick Date: Tue, 24 Jul 2012 15:05:28 -0700 Subject: cherrypick from jb-dev docs: GCM changes Change-Id: Id5454e70455bae14ab4605021a6c1bcab0292ae9 Conflicts: docs/html/guide/google/gcm/gcm.jd Conflicts: docs/html/guide/google/gcm/gcm.jd Change-Id: I584ba81e923d4150d2b4aed940d790c8298bae7c --- docs/html/guide/google/gcm/gcm.jd | 29 +++++++++++++++++++++++------ docs/html/guide/google/gcm/index.jd | 2 ++ 2 files changed, 25 insertions(+), 6 deletions(-) (limited to 'docs/html') diff --git a/docs/html/guide/google/gcm/gcm.jd b/docs/html/guide/google/gcm/gcm.jd index 1b95520bf78f..827edaa731d0 100644 --- a/docs/html/guide/google/gcm/gcm.jd +++ b/docs/html/guide/google/gcm/gcm.jd @@ -56,7 +56,7 @@ page.title=GCM Architectural Overview -

Google Cloud Messaging for Android (GCM) is a service that helps +

Google Cloud Messaging for Android (GCM) is a free service that helps developers send data from servers to their Android applications on Android devices. This could be a lightweight message telling the Android application that there is new data to be fetched from the server (for instance, a movie uploaded by a friend), or it could be a message containing up to 4kb of payload data (so apps like instant messaging can consume the message directly). The GCM service handles all aspects of queueing of messages and delivery to the target Android application running on the target device.

@@ -545,7 +545,8 @@ private void handleRegistration(Intent intent) {

The com.google.android.c2dm.intent.RECEIVE intent is used by GCM to deliver the messages sent by the 3rd-party server to the application running in the device. If the server included key-pair values in the data parameter, they are available as -extras in this intent, with the keys being the extra names. +extras in this intent, with the keys being the extra names. GCM also includes an extra called +from which contains the sender ID as an string.

Here is an example, again using the MyIntentReceiver class:

@@ -652,7 +653,9 @@ message sent by the application server. See Advan data A JSON object whose fields represents the key-value pairs of the message's payload data. If present, the payload data it will be included in the Intent as application data, with the key being the extra's name. For instance, "data":{"score":"3x1"} would result in an intent extra named score whose value is the string 3x1. -There is no limit on the number of key/value pairs, though there is a limit on the total size of the message (4kb). Note that the values must be enclosed by strings. If you want to include objects or other non-string data types (such as integers or booleans), you have to do the conversion to string yourself. Optional. + +There is no limit on the number of key/value pairs, though there is a limit on the total size of the message (4kb). Note that the values must be enclosed by strings. If you want to include objects or other non-string data types (such as integers or booleans), you have to do the conversion to string yourself. Also note that the key cannot be a reserved word ("from" or any word starting with "google."). Optional. + delay_while_idle @@ -683,7 +686,7 @@ sent. Optional. The default value is false, and must be a JSON bool data.<key> - Payload data, expressed as parameters prefixed with data. and suffixed as the key. For instance, a parameter of data.score=3x1 would result in an intent extra named score whose value is the string 3x1. There is no limit on the number of key/value parameters, though there is a limit on the total size of the message. Optional. + Payload data, expressed as parameters prefixed with data. and suffixed as the key. For instance, a parameter of data.score=3x1 would result in an intent extra named score whose value is the string 3x1. There is no limit on the number of key/value parameters, though there is a limit on the total size of the message. Note that the key cannot be a reserved word ("from" or any word starting with "google."). Optional. delay_while_idle @@ -879,8 +882,20 @@ messages.
  • Request originated from a server not whitelisted in the Server Key IPs.
  • -Check that the token you're sending inside the Authorization header is the correct API key associated with your project.
    +Check that the token you're sending inside the Authorization header is the correct API key associated with your project. You can check the validity of your API key by running the following command:
    + +
    # api_key=YOUR_API_KEY
    +
    +# curl --header "Authorization: key=$api_key" --header Content-Type:"application/json" https://android.googleapis.com/gcm/send  -d "{\"registration_ids\":[\"ABC\"]}"
    + +If you receive a 401 HTTP status code, your API key is not valid. Otherwise you should see something like this:
    + +
    +{"multicast_id":6782339717028231855,"success":0,"failure":1,"canonical_ids":0,"results":[{"error":"InvalidRegistration"}]}
    +
    +If you want to confirm the validity of a registration ID, you can do so by replacing "ABC" with the registration ID. +
    Happens when the HTTP status code is 401.
    Timeout
    @@ -974,7 +989,7 @@ registration_id=32

    To view statistics and any error messages for your GCM applications:

      -
    1. Go to play.google.com/apps/publish.
    2. +
    3. Go to the Android Developer Console.
    4. Login with your developer account.

      You will see a page that has a list of all of your apps.

    5. Click on the "statistics" link next to the app for which you want to view GCM stats. @@ -982,6 +997,8 @@ registration_id=32
    6. Go to the drop-down menu and select the GCM metric you want to view.
    +

    Note: Stats on the Google API Console are not enabled for GCM. You must use the Android Developer Console.

    +

    Examples

    See the GCM Demo Application document.

    diff --git a/docs/html/guide/google/gcm/index.jd b/docs/html/guide/google/gcm/index.jd index 140b0762967a..8079ebae6e2c 100644 --- a/docs/html/guide/google/gcm/index.jd +++ b/docs/html/guide/google/gcm/index.jd @@ -5,6 +5,8 @@ page.title=Google Cloud Messaging for Android

    Google Cloud Messaging for Android (GCM) is a service that helps developers send data from servers to their Android applications on Android devices. This could be a lightweight message telling the Android application that there is new data to be fetched from the server (for instance, a movie uploaded by a friend), or it could be a message containing up to 4kb of payload data (so apps like instant messaging can consume the message directly). The GCM service handles all aspects of queueing of messages and delivery to the target Android application running on the target device.

    +

    GCM is completely free no matter how big your messaging needs are, and there are no quotas.

    +

    To learn more about GCM, you can join the android-gcm group and read the following documents:

    -- cgit v1.2.3-59-g8ed1b