From f788ac1ab144dab29466daadc662d42c66daf2f1 Mon Sep 17 00:00:00 2001 From: kmccormick Date: Thu, 30 May 2013 19:06:41 -0700 Subject: Doc update: Refactoring to client/server. Change-Id: I14e958958e69a6a56d2cc6da70b9123febd9955b --- docs/html/google/gcm/ccs.jd | 70 +--- docs/html/google/gcm/client.jd | 24 ++ docs/html/google/gcm/demo.jd | 16 + docs/html/google/gcm/gcm.jd | 347 -------------------- docs/html/google/gcm/gs.jd | 364 ++++++++++++++++----- docs/html/google/gcm/helper.jd | 17 + docs/html/google/gcm/index.jd | 3 + docs/html/google/gcm/notifications.jd | 3 + docs/html/google/gcm/server.jd | 160 +++++++++ docs/html/google/google_toc.cs | 8 +- .../google/android/gcm/GCMBaseIntentService.html | 3 + .../google/android/gcm/GCMBroadcastReceiver.html | 4 + .../com/google/android/gcm/GCMConstants.html | 2 + .../com/google/android/gcm/GCMRegistrar.html | 4 + .../com/google/android/gcm/package-summary.html | 10 +- docs/html/reference/gcm-packages.html | 5 +- 16 files changed, 532 insertions(+), 508 deletions(-) create mode 100644 docs/html/google/gcm/client.jd create mode 100644 docs/html/google/gcm/server.jd diff --git a/docs/html/google/gcm/ccs.jd b/docs/html/google/gcm/ccs.jd index ffe15c5..0cadbd2 100644 --- a/docs/html/google/gcm/ccs.jd +++ b/docs/html/google/gcm/ccs.jd @@ -23,7 +23,7 @@ page.title=GCM Cloud Connection Server
  • Message Examples
  • -
  • Control Flow
  • +
  • Flow Control
  • See Also

    @@ -48,6 +48,8 @@ page.title=GCM Cloud Connection Server

    The upstream messaging (device-to-cloud) feature of CCS is part of the Google Play services platform. Upstream messaging is available through the {@code GoogleCloudMessaging} APIs. To use upstream messaging and the new streamlined registration process, you must set up the Google Play services SDK.

    +

    Note: For an example of an XMPP server, see GCM Server. +

    CCS vs. GCM HTTP

    CCS messaging differs from GCM HTTP messaging in the following ways:

    @@ -229,69 +231,13 @@ gcm.send(GCM_SENDER_ID + "@gcm.googleapis.com", id, ttl, data); </gcm> </message> -

    Python Example

    -

    This example illustrates how to connect, -send, and receive GCM messages using XMPP. It shouldn't be used as-is -on a production deployment.

    - -
    -import sys, json, xmpp
    -SERVER = ('gcm.googleapis.com', 5235)
    -#USERNAME = '<your_numeric_project_id>'
    -#PASSWORD = '<your_gcm_api_key>'
    -
    -# Unique message id for downstream messages
    -sent_message_id = 0
    -
    -def message_callback(session, message):
    -  global sent_message_id
    -  gcm = message.getTags('gcm')
    -
    -  if gcm:
    -    gcm_json = gcm[0].getData()
    -    msg = json.loads(gcm_json)
    -    msg_id = msg['message_id']
    -    device_reg_id = msg['from']
    -
    -    # Ignore non-standard messages (e.g. acks/nacks).
    -    if not msg.has_key('message_type'):
    -      # Acknowledge the incoming message.
    -      send({'to': device_reg_id,
    -            'message_type': 'ack',
    -            'message_id': msg_id})
     
    -      # Send a response back to the server.
    -      send({'to': device_reg_id,
    -            'message_id' : str(sent_message_id),
    -            'data': {'pong': 1}})
    -      sent_message_id = sent_message_id + 1
    +

    Flow Control

    -def send(json_dict): - template = ("<message from='{0}' to='gcm@google.com'>" - "<gcm xmlns='google:mobile:data'>{1}</gcm></message>") - client.send(xmpp.protocol.Message( - node=template.format(client.Bind.bound[0], - json.dumps(json_dict)))) +

    Every message sent to CCS receives either an ACK or a NACK response. Messages that haven't received one of these responses are considered pending. If the pending message count reaches 1000, the 3rd-party server should stop sending new messages and wait for CCS to acknowledge some of the existing pending messages.

    -client = xmpp.Client(SERVER[0], debug=['socket']) -client.connect(server=SERVER, secure=1, use_srv=False) -auth = client.auth(USERNAME, PASSWORD, 'test') -if not auth: - print 'Authentication failed!' - sys.exit(1) +

    Conversely, to avoid overloading the 3rd-party server, CCS will stop sending if there are too many unacknowledged messages. Therefore, the 3rd-party server should "ACK" received messages as soon as possible to maintain a constant flow of incoming messages. The aforementioned pending message limit doesn't apply to these ACKs. Even if the pending message count reaches 1000, the 3rd-party server should continue sending ACKs to avoid blocking delivery of new messages.

    -client.RegisterHandler('message', message_callback) - -while True: - client.Process(1)
    - -

    Control Flow

    - -

    Every message sent by a 3rd-party server to CCS receives either an ACK or a NACK response. A single connection can have at most 1000 messages that were sent without having yet received a response.

    - -

    To enforce this policy, the app can maintain a counter of sent messages that increments on each send and decrements on each ACK or NACK. If the counter exceeds 1000, the app should stop sending messages until an ACK or NACK is received.

    - -

    Conversely, when CCS sends messages to a 3rd-party server, it expects ACKs for each message it sends, and it will not send more than 1000 unacknowledged messages.

    - -

    The ACKs and messages must match on each connection. You can only send an ACK for a message on the connection on which it was received.

    +

    ACKs are only valid within the context of one connection. If the connection is closed before a message can be ACKed, the 3rd-party server should wait for CCS to resend the message before ACKing it again. +

    diff --git a/docs/html/google/gcm/client.jd b/docs/html/google/gcm/client.jd new file mode 100644 index 0000000..7604932 --- /dev/null +++ b/docs/html/google/gcm/client.jd @@ -0,0 +1,24 @@ +page.title=GCM Client +page.tags="cloud","push","messaging" +@jd:body + +
    +
    + +

    See Also

    + +
      +
    1. Getting Started
    2. +
    3. GCM Server
    4. +
    + +
    +
    + +

    A GCM client is a GCM-enabled app that runs on an Android device. To write your client code, we recommend that you use the new {@code GoogleCloudMessaging} APIs. The client helper library that was offered in previous versions of GCM still works, but it has been superseded by the more efficient {@code GoogleCloudMessaging} APIs.

    + +

    A full GCM implementation requires both a client implementation and a server-side implementation. For a step-by-step guide to creating a complete sample implementation that includes both client and server, see Getting Started.

    + +

    + + diff --git a/docs/html/google/gcm/demo.jd b/docs/html/google/gcm/demo.jd index 6da9e98..012eb9a 100644 --- a/docs/html/google/gcm/demo.jd +++ b/docs/html/google/gcm/demo.jd @@ -1,6 +1,22 @@ page.title=GCM Demo Application @jd:body +

    + + This doc is deprecated +
    + + +
    +

    The information in this document has been superseded by GCM Server and GCM Client. Please use the {@code GoogleCloudMessaging} API instead of the GCM client helper library. The GCM server helper library is still valid.

    + + +
    +
    +
    diff --git a/docs/html/google/gcm/gcm.jd b/docs/html/google/gcm/gcm.jd index 7486d7b..3d99a75 100644 --- a/docs/html/google/gcm/gcm.jd +++ b/docs/html/google/gcm/gcm.jd @@ -28,20 +28,6 @@ page.title=Google Cloud Messaging for Android
  • What Does the User See?
  • -
  • Writing Android Applications that use GCM -
      -
    1. Creating the Manifest
    2. -
    3. Registering for GCM
    4. - -
    5. Handling Intents Sent by GCM -
        -
      1. Handling Registration Results
      2. -
      3. Handling Received Data
      4. -
      -
    6. -
    7. Developing and Testing Your Android Applications
    8. -
    -
  • Role of the 3rd-party Application Server
    1. Sending Messages @@ -53,7 +39,6 @@ page.title=Google Cloud Messaging for Android
  • Viewing Statistics
  • -
  • Examples
  • @@ -306,336 +291,6 @@ from the com.google.android.c2dm.intent.RECEIVE Intent includes GCM. They must approve the use of this feature to install the Android application.

    -

    Writing Android Applications that Use GCM

    - -

    To write Android applications that use GCM, you must have an application -server that can perform the tasks described in Role of the -3rd-party Application Server. This section describes the steps you take to -create a client application that uses GCM.

    - -

    Remember that there is no user interface associated with GCM. -However you choose to process messages in your Android application is up to you.

    - -

    There are two primary steps involved in writing a client Android application:

    - -
      -
    • Creating a manifest that contains the permissions the Android application needs to -use GCM.
    • -
    • Implementing your code. To use GCM, this implementation must -include: -
        -
      • Code to start and stop the registration service.
      • -
      • Receivers for the com.google.android.c2dm.intent.RECEIVE and com.google.android.c2dm.intent.REGISTRATION intents.
      • -
      -
    • -
    - -

    Note: This section describes how to -write an app without using the -helper libraries. -For details on writing -an app that uses the helper libraries (which is the recommended and -simpler approach), see GCM: Getting Started. - -

    Creating the Manifest

    - -

    To use the GCM feature, the -AndroidManifest.xml file must include the following:

    - -
      -
    • The com.google.android.c2dm.permission.RECEIVE permission so the Android application can register and receive messages.
    • -
    • The android.permission.INTERNET permission so the Android application can send the registration ID to the 3rd-party server.
    • -
    • The android.permission.GET_ACCOUNTS permission as GCM requires a Google account (necessary only if if the device is running a version lower than Android 4.0.4)
    • -
    • The android.permission.WAKE_LOCK permission so the application can keep the processor from sleeping when a message is received. Optional—use only if the app wants to keep the device from sleeping.
    • -
    • An applicationPackage + ".permission.C2D_MESSAGE permission to prevent other Android applications from registering and receiving the Android application's -messages. The permission name must exactly match this pattern—otherwise the Android application will not receive the messages.
    • -
    • A receiver for com.google.android.c2dm.intent.RECEIVE and com.google.android.c2dm.intent.REGISTRATION, with the category set -as applicationPackage. The receiver should require the com.google.android.c2dm.SEND permission, so that only the GCM -Framework can send a message to it. Note that both registration and the receiving -of messages are implemented as Intents.
    • -
    • An intent service to handle the intents received by the broadcast receiver. Optional.
    • -
    • If the GCM feature is critical to the Android application's function, be sure to -set android:minSdkVersion="8" in the manifest. This -ensures that the Android application cannot be installed in an environment in which it -could not run properly.
    • -
    - -

    Here are excerpts from a manifest that supports GCM:

    - -
    -<manifest package="com.example.gcm" ...>
    -
    -    <uses-sdk android:minSdkVersion="8" android:targetSdkVersion="16"/>
    -    <uses-permission android:name="android.permission.INTERNET" />
    -    <uses-permission android:name="android.permission.GET_ACCOUNTS" />
    -    <uses-permission android:name="android.permission.WAKE_LOCK" />
    -    <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
    -
    -    <permission android:name="com.example.gcm.permission.C2D_MESSAGE" 
    -        android:protectionLevel="signature" />
    -    <uses-permission android:name="com.example.gcm.permission.C2D_MESSAGE" />
    -
    -    <application ...>
    -        <receiver
    -            android:name=".MyBroadcastReceiver"
    -            android:permission="com.google.android.c2dm.permission.SEND" >
    -            <intent-filter>
    -                <action android:name="com.google.android.c2dm.intent.RECEIVE" />
    -                <action android:name="com.google.android.c2dm.intent.REGISTRATION" />
    -                <category android:name="com.example.gcm" />
    -            </intent-filter>
    -        </receiver>
    -        <service android:name=".MyIntentService" />
    -    </application>
    -
    -</manifest>
    -
    - -

    Registering for GCM

    - - - -

    An Android application needs to register with GCM servers before it can receive messages. To register, the application sends an Intent -(com.google.android.c2dm.intent.REGISTER), with 2 extra parameters: -

    - -
      -
    • sender is the project number of the account authorized to send messages -to the Android application.
    • -
    • app is the Android application's ID, set with a PendingIntent to -allow the registration service to extract Android application information.
    • -
    - -

    For example:

    - -
    Intent registrationIntent = new Intent("com.google.android.c2dm.intent.REGISTER");
    -// sets the app name in the intent
    -registrationIntent.putExtra("app", PendingIntent.getBroadcast(this, 0, new Intent(), 0));
    -registrationIntent.putExtra("sender", senderID);
    -startService(registrationIntent);
    - -

    This intent will be asynchronously sent to the GCM server, and the response will be delivered to -the application as a com.google.android.c2dm.intent.REGISTRATION intent containing -the registration ID assigned to the Android application running on that particular device.

    - -

    Registration is not complete until the Android application sends the registration ID -to the 3rd-party application server, which in turn will use the registration ID to send -messages to the application.

    - -

    Unregistering from GCM

    - -

    To unregister from GCM, do the following:

    - -
    Intent unregIntent = new Intent("com.google.android.c2dm.intent.UNREGISTER");
    -unregIntent.putExtra("app", PendingIntent.getBroadcast(this, 0, new Intent(), 0));
    -startService(unregIntent);
    -
    - -

    Similar to the registration request, this intent is sent asynchronously, and the response comes as a com.google.android.c2dm.intent.REGISTRATION intent. - - -

    Handling Intents sent by GCM

    - -

    As discussed in Creating the Manifest, the manifest -defines a broadcast receiver for the com.google.android.c2dm.intent.REGISTRATION and com.google.android.c2dm.intent.RECEIVE intents. -These intents are sent by GCM to indicate that a device was registered (or unregistered), or to deliver messages, respectively.

    - -

    Handling these intents might require I/O operations (such as network calls to the 3rd-party server), and -such operations should not be done in the receiver's onReceive() method. -You may be tempted to spawn a new thread directly, but there are no guarantees that the process will run long enough for the thread to finish the work. -Thus the recommended way to handle the intents is to delegate them to a service, such as an {@link android.app.IntentService}. -For example:

    - - -
    -public class MyBroadcastReceiver extends BroadcastReceiver {
    -
    -    @Override
    -    public final void onReceive(Context context, Intent intent) {
    -        MyIntentService.runIntentInService(context, intent);
    -        setResult(Activity.RESULT_OK, null, null);
    -    }
    -}
    -
    - -

    Then in MyIntentService:

    -
    -public class MyIntentService extends IntentService {
    -
    -    private static PowerManager.WakeLock sWakeLock;
    -    private static final Object LOCK = MyIntentService.class;
    -    
    -    static void runIntentInService(Context context, Intent intent) {
    -        synchronized(LOCK) {
    -            if (sWakeLock == null) {
    -                PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
    -                sWakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "my_wakelock");
    -            }
    -        }
    -        sWakeLock.acquire();
    -        intent.setClassName(context, MyIntentService.class.getName());
    -        context.startService(intent);
    -    }
    -    
    -    @Override
    -    public final void onHandleIntent(Intent intent) {
    -        try {
    -            String action = intent.getAction();
    -            if (action.equals("com.google.android.c2dm.intent.REGISTRATION")) {
    -                handleRegistration(intent);
    -            } else if (action.equals("com.google.android.c2dm.intent.RECEIVE")) {
    -                handleMessage(intent);
    -            }
    -        } finally {
    -            synchronized(LOCK) {
    -                sWakeLock.release();
    -            }
    -        }
    -    }
    -}
    -
    - -

    Note: your application must acquire a wake lock before starting the service—otherwise the device could be put to sleep before the service is started.

    - -

    Handling Registration Results

    - -

    When a com.google.android.c2dm.intent.REGISTRATION intent is received, it could potentially contain 3 extras: registration_id, error, and unregistered. - -

    When a registration succeeds, registration_id contains the registration ID and the other extras are not set. -The application must ensure that the 3rd-party server receives the registration ID. It may do so by saving the registration ID and sending it to the server. -If the network is down or there are errors, the application should retry sending the registration ID when the network is up again or the next time it starts.

    - -

    Note: Although the com.google.android.c2dm.intent.REGISTRATION intent is typically received after a request was made by the application, -Google may periodically refresh the registration ID. So the application must be prepared to handle it at any time.

    - -

    When an unregistration succeeds, only the unregistered extra is set, and similar to the registration workflow, -the application must contact the 3rd-party server to remove the registration ID (note that the registration ID is not available in the intent, -but the application should have saved the registration ID when it got it).

    - -

    If the application request (be it register or unregister) fails, the error will be set with an error code, and the other extras will not be set. - -Here are the possible error codes:

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    Error CodeDescription
    SERVICE_NOT_AVAILABLEThe device can't read the response, or there was a 500/503 from the -server that can be retried later. The Android application should use exponential back-off and retry. See Advanced Topics for more information.
    ACCOUNT_MISSINGThere is no Google account on the phone. The Android application should ask the -user to open the account manager and add a Google account. Fix on the device -side.
    AUTHENTICATION_FAILEDBad Google Account password. The Android application should ask the user to enter his/her Google Account -password, and let the user retry manually later. Fix on the device side.
    INVALID_SENDERThe sender account is not recognized. This must be fixed on the Android application side. The developer must fix the application to provide the right sender extra in the com.google.android.c2dm.intent.REGISTER intent.
    PHONE_REGISTRATION_ERROR Incorrect phone registration with Google. This -phone doesn't currently support GCM.
    INVALID_PARAMETERSThe request sent by the phone does not contain the expected parameters. This phone doesn't currently support GCM.
    - - - - -

    Here's an example on how to handle the registration in the MyIntentService example:

    - -
    -private void handleRegistration(Intent intent) {
    -    String registrationId = intent.getStringExtra("registration_id");
    -    String error = intent.getStringExtra("error");
    -    String unregistered = intent.getStringExtra("unregistered");
    -    // registration succeeded
    -    if (registrationId != null) {
    -        // store registration ID on shared preferences
    -        // notify 3rd-party server about the registered ID
    -    }
    -        
    -    // unregistration succeeded
    -    if (unregistered != null) {
    -        // get old registration ID from shared preferences
    -        // notify 3rd-party server about the unregistered ID
    -    } 
    -        
    -    // last operation (registration or unregistration) returned an error;
    -    if (error != null) {
    -        if ("SERVICE_NOT_AVAILABLE".equals(error)) {
    -           // optionally retry using exponential back-off
    -           // (see Advanced Topics)
    -        } else {
    -            // Unrecoverable error, log it
    -            Log.i(TAG, "Received error: " + error);
    -        }
    -    }
    -}
    - - - -

    Handling Received Data

    - -

    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. GCM also includes an extra called -from which contains the sender ID as an string, and another called collapse_key containing the collapse key (when in use). - -

    Here is an example, again using the MyIntentReceiver class:

    - -
    -private void handleMessage(Intent intent) {
    -    // server sent 2 key-value pairs, score and time
    -    String score = intent.getExtra("score");
    -    String time = intent.getExtra("time");
    -    // generates a system notification to display the score and time
    -}
    - -

    Developing and Testing Your Android Applications

    - -

    Here are some guidelines for developing and testing an Android application -that uses the GCM feature:

    - -
      -
    • To develop and test your Android applications, you need to run and debug the -applications on an Android 2.2 system image that includes the necessary -underlying Google services.
    • -
    • To develop and debug on an actual device, you need a device running an -Android 2.2 system image that includes the Google Play Store application.
    • -
    • To develop and test on the Android Emulator, you need to download the -Android 2.2 version of the Google APIs Add-On into your SDK using the Android -SDK and AVD Manager. Specifically, you need to download the component named -"Google APIs by Google Inc, Android API 8". Then, you need to set up -an AVD that uses that system image.
    • -
    • If the GCM feature is critical to the Android application's function, be sure to -set android:minSdkVersion="8" in the manifest. This -ensures that the Android application cannot be installed in an environment in which it -could not run properly.
    • -
    -

    Role of the 3rd-party Application Server

    @@ -1104,6 +759,4 @@ registration_id=32

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

    -

    Examples

    -

    See the GCM Demo Application document.

    diff --git a/docs/html/google/gcm/gs.jd b/docs/html/google/gcm/gs.jd index d938bd6..8ceea0cc 100644 --- a/docs/html/google/gcm/gs.jd +++ b/docs/html/google/gcm/gs.jd @@ -12,14 +12,14 @@ page.tags="cloud","push","messaging"
  • Creating a Google API Project
  • Enabling the GCM Service
  • Obtaining an API Key
  • -
  • Writing the Android Application +
  • Writing a Client App
  • +
  • Writing the Server Code
  • See Also

    1. Google APIs Console page
    2. -
    3. Using the GCM Helper Libraries
    4. CCS and User Notifications Signup Form
    @@ -29,20 +29,9 @@ page.tags="cloud","push","messaging"

    The sections below guide you through the process of setting up a GCM implementation. Before you start, make sure to set up -the Google Play Services SDK. You need this SDK to use the {@code GoogleCloudMessaging} methods. Strictly speaking, the only thing you absolutely need this API for is upstream (device-to-cloud) messaging, but it also offers a streamlined registration API that is recommended.

    - - - - +the Google Play Services SDK. You need this SDK to use the {@code GoogleCloudMessaging} methods.

    +

    Note that a full GCM implementation requires a server-side implementation, in addition to the client implementation in your app. This document offers a complete example that includes both the client and server.

    Creating a Google API project

    @@ -95,17 +84,21 @@ the Google Play Services SDK. You need this SDK to use the Note: If you need to rotate the key, click Generate new key. A new key will be created while the old one will still be active for up to 24 hours. If you want to get rid of the old key immediately (for example, if you feel it was compromised), click Delete key.

    +

    The following sections walk you through the steps of creating client and server-side code.

    -

    Writing the Android Application

    -

    This section describes the steps involved in writing an Android application that uses GCM.

    +

    Writing a Client App

    -

    Step 1: Make the following changes in the application's Android manifest

    +

    This section walks you through the steps involved in writing a client-side application—that is, the GCM-enabled application that runs on an Android device. This client sample is designed to work in conjunction with the server code shown in Writing the Server Code, below.

    + + + +

    Step 1: Edit Your App's Manifest

    • The com.google.android.c2dm.permission.RECEIVE permission so the Android application can register and receive messages.
    • The android.permission.INTERNET permission so the Android application can send the registration ID to the 3rd party server.
    • The android.permission.GET_ACCOUNTS permission as GCM requires a Google account (necessary only if if the device is running a version lower than Android 4.0.4)
    • The android.permission.WAKE_LOCK permission so the application can keep the processor from sleeping when a message is received. Optional—use only if the app wants to keep the device from sleeping.
    • -
    • An applicationPackage + ".permission.C2D_MESSAGE permission to prevent other Android applications from registering and receiving the Android application's +
    • An applicationPackage + ".permission.C2D_MESSAGE" permission to prevent other Android applications from registering and receiving the Android application's messages. The permission name must exactly match this pattern—otherwise the Android application will not receive the messages.
    • A receiver for com.google.android.c2dm.intent.RECEIVE, with the category set as applicationPackage. The receiver should require the com.google.android.c2dm.SEND permission, so that only the GCM @@ -149,106 +142,199 @@ could not run properly.
    • -

      Step 2: Register for GCM

      +

      Step 2: Register for GCM

      An Android application running on a mobile device registers to receive messages by calling the {@code GoogleCloudMessaging} method {@code register(senderID...)}. This method registers the application for GCM and returns the registration ID. This streamlined approach replaces the previous -GCM registration process.

      +GCM registration process. See the example below for details.

      -

      Step 3: Write your application

      +

      Step 3: Write Your Application

      Finally, write your application. GCM offers a variety of ways to get the job done:

      -
      Example
      +

      Example

      -

      Here is a sample application that illustrates how to use the {@code GoogleCloudMessaging} APIs. In this example, the sender is a CCS echo server. The sample consists of a main Activity ({@code DemoActivity}) and a broadcast receiver ({@code GcmBroadcastReceiver}).

      +

      Here is a sample client application that illustrates how to use the {@code GoogleCloudMessaging} APIs. The sample consists of a main activity ({@code DemoActivity}) and a broadcast receiver ({@code GcmBroadcastReceiver}). You can use this client sample code in conjunction with the server code shown in Writing the Server Code.

      +

      Note the following:

      + +
        +
      • The sample primarily illustrates two things: registration, and upstream messaging. Upstream messaging only applies to apps that are running against a CCS server; HTTP-based servers don't support upstream messaging.
      • +
      • The {@code GoogleCloudMessaging} registration APIs replace the old registration process, which was based on the now-obsolete client helper library. While the old registration process still works, we encourage you to use the newer {@code GoogleCloudMessaging} registration APIs, regardless of your underlying server.
      • +
      + +
      Registering

      An Android application needs to register with GCM servers before it can receive messages. So in its {@code onCreate()} method, {@code DemoActivity} checks to see whether the app is registered with GCM and with the server:

      -
      public class DemoActivity extends Activity {
      +
      /**
      + * Main UI for the demo app.
      + */
      +public class DemoActivity extends Activity {
       
           public static final String EXTRA_MESSAGE = "message";
           public static final String PROPERTY_REG_ID = "registration_id";
      +    private static final String PROPERTY_APP_VERSION = "appVersion";
      +    private static final String PROPERTY_ON_SERVER_EXPIRATION_TIME =
      +            "onServerExpirationTimeMs";
      +    /**
      +     * Default lifespan (7 days) of a reservation until it is considered expired.
      +     */
      +    public static final long REGISTRATION_EXPIRY_TIME_MS = 1000 * 3600 * 24 * 7;
      +
           /**
      -     * You can use your own project ID instead. This sender is a test CCS 
      -     * echo server.
      +     * Substitute you own sender ID here.
            */
      -    String GCM_SENDER_ID = "Your-Sender-ID";
      +    String SENDER_ID = "Your-Sender-ID";
       
      -    // Tag for log messages.
      +    /**
      +     * Tag used on log messages.
      +     */
           static final String TAG = "GCMDemo";
       
           TextView mDisplay;
           GoogleCloudMessaging gcm;
           AtomicInteger msgId = new AtomicInteger();
           SharedPreferences prefs;
      +    Context context;
      +
           String regid;
       
           @Override
           public void onCreate(Bundle savedInstanceState) {
               super.onCreate(savedInstanceState);
       
      -        // Make sure the app is registered with GCM and with the server
      -        prefs = getSharedPreferences(DemoActivity.class.getSimpleName(), 
      -                Context.MODE_PRIVATE);
               setContentView(R.layout.main);
      -
               mDisplay = (TextView) findViewById(R.id.display);
       
      -        regid = prefs.getString(PROPERTY_REG_ID, null);
      - 
      -        // If there is no registration ID, the app isn't registered.
      -        // Call registerBackground() to register it.
      -        if (regid == null) {
      +        context = getApplicationContext();
      +        regid = getRegistrationId(context);
      +
      +        if (regid.length() == 0) {
                   registerBackground();
               }
      -
               gcm = GoogleCloudMessaging.getInstance(this);
      -    }
      + } +... +}
      + +

      The app calls {@code getRegistrationId()} to see whether there is an existing registration ID stored in shared preferences:

      + +
      /**
      + * Gets the current registration id for application on GCM service.
      + * <p>
      + * If result is empty, the registration has failed.
      + *
      + * @return registration id, or empty string if the registration is not
      + *         complete.
      + */
      +private String getRegistrationId(Context context) {
      +    final SharedPreferences prefs = getGCMPreferences(context);
      +    String registrationId = prefs.getString(PROPERTY_REG_ID, "");
      +    if (registrationId.length() == 0) {
      +        Log.v(TAG, "Registration not found.");
      +        return "";
      +    }
      +    // check if app was updated; if so, it must clear registration id to
      +    // avoid a race condition if GCM sends a message
      +    int registeredVersion = prefs.getInt(PROPERTY_APP_VERSION, Integer.MIN_VALUE);
      +    int currentVersion = getAppVersion(context);
      +    if (registeredVersion != currentVersion || isRegistrationExpired()) {
      +        Log.v(TAG, "App version changed or registration expired.");
      +        return "";
      +    }
      +    return registrationId;
      +}
      +
      +...
      +
      +/**
      + * @return Application's {@code SharedPreferences}.
      + */
      +private SharedPreferences getGCMPreferences(Context context) {
      +    return getSharedPreferences(DemoActivity.class.getSimpleName(), 
      +            Context.MODE_PRIVATE);
      +}
      + +

      If the registration ID doesn't exist, or the app was updated, or the registration ID has expired, {@code getRegistrationId()} returns an empty string to indicate that the app needs to get a new regID. {@code getRegistrationId()} calls the following methods to check the app version and whether the regID has expired:

      + +
      /**
      + * @return Application's version code from the {@code PackageManager}.
      + */
      +private static int getAppVersion(Context context) {
      +    try {
      +        PackageInfo packageInfo = context.getPackageManager()
      +                .getPackageInfo(context.getPackageName(), 0);
      +        return packageInfo.versionCode;
      +    } catch (NameNotFoundException e) {
      +        // should never happen
      +        throw new RuntimeException("Could not get package name: " + e);
      +    }
      +}
      +
      +/**
      + * Checks if the registration has expired.
      + *
      + * <p>To avoid the scenario where the device sends the registration to the
      + * server but the server loses it, the app developer may choose to re-register
      + * after REGISTRATION_EXPIRY_TIME_MS.
      + *
      + * @return true if the registration has expired.
      + */
      +private boolean isRegistrationExpired() {
      +    final SharedPreferences prefs = getGCMPreferences(context);
      +    // checks if the information is not stale
      +    long expirationTime =
      +            prefs.getLong(PROPERTY_ON_SERVER_EXPIRATION_TIME, -1);
      +    return System.currentTimeMillis() > expirationTime;
      +}
      + -

      If the app isn't registered, {@code DemoActivity} calls the following {@code registerBackground()} method to register it. Note that because GCM methods are blocking, this has to take place on a background thread. This sample uses {@link android.os.AsyncTask} to accomplish this:

      +

      If there isn't a valid existing registration ID, {@code DemoActivity} calls the following {@code registerBackground()} method to register. Note that because GCM methods are blocking, this has to take place on a background thread. This sample uses {@link android.os.AsyncTask} to accomplish this:

      -
      private void registerBackground() {
      +
      +/**
      + * Registers the application with GCM servers asynchronously.
      + * <p>
      + * Stores the registration id, app versionCode, and expiration time in the 
      + * application's shared preferences.
      + */
      +private void registerBackground() {
           new AsyncTask() {
               @Override
               protected String doInBackground(Void... params) {
                   String msg = "";
                   try {
      -                regid = gcm.register(GCM_SENDER_ID);
      +                if (gcm == null) {
      +                    gcm = GoogleCloudMessaging.getInstance(context);
      +                }
      +                regid = gcm.register(SENDER_ID);
                       msg = "Device registered, registration id=" + regid;
       
      -                // You should send the registration ID to your server over HTTP, 
      +                // You should send the registration ID to your server over HTTP,
                       // so it can use GCM/HTTP or CCS to send messages to your app.
       
      -                // For this demo: we don't need to send it because the device  
      -                // will send upstream messages to a server that will echo back 
      -                // the message using the 'from' address in the message. 
      -	
      -                // Save the regid for future use - no need to register again.
      -                SharedPreferences.Editor editor = prefs.edit();
      -                editor.putString(PROPERTY_REG_ID, regid);
      -                editor.commit();
      +                // For this demo: we don't need to send it because the device
      +                // will send upstream messages to a server that echo back the message
      +                // using the 'from' address in the message.
      +
      +                // Save the regid - no need to register again.
      +                setRegistrationId(context, regid);
                   } catch (IOException ex) {
                       msg = "Error :" + ex.getMessage();
                   }
                   return msg;
               }
      -        // Once registration is done, display the registration status
      -        // string in the Activity's UI.
      +
               @Override
               protected void onPostExecute(String msg) {
                   mDisplay.append(msg + "\n");
      @@ -256,7 +342,33 @@ GCM registration process.

      }.execute(null, null, null); }
      -

      When the user clicks the app's Echo button, the app generates the necessary XMPP stanza for the message, which it sends to the echo server:

      +

      After registering, the app calls {@code setRegistrationId()} to store the registration ID in shared preferences for future use:

      + +
      /**
      + * Stores the registration id, app versionCode, and expiration time in the
      + * application's {@code SharedPreferences}.
      + *
      + * @param context application's context.
      + * @param regId registration id
      + */
      +private void setRegistrationId(Context context, String regId) {
      +    final SharedPreferences prefs = getGCMPreferences(context);
      +    int appVersion = getAppVersion(context);
      +    Log.v(TAG, "Saving regId on app version " + appVersion);
      +    SharedPreferences.Editor editor = prefs.edit();
      +    editor.putString(PROPERTY_REG_ID, regId);
      +    editor.putInt(PROPERTY_APP_VERSION, appVersion);
      +    long expirationTime = System.currentTimeMillis() + REGISTRATION_EXPIRY_TIME_MS;
      +
      +    Log.v(TAG, "Setting registration expiry time to " +
      +            new Timestamp(expirationTime));
      +    editor.putLong(PROPERTY_ON_SERVER_EXPIRATION_TIME, expirationTime);
      +    editor.commit();
      +}
      + +
      Sending a message
      +

      When the user clicks the app's Send button, the app sends an upstream message using the new {@code GoogleCloudMessaging} APIs. In order to receive the upstream message, your server should be connected to CCS. You can use the code shown in Writing the Server Code as a sample XMPP client to connect to CCS.

      +
      public void onClick(final View view) {
           if (view == findViewById(R.id.send)) {
               new AsyncTask() {
      @@ -265,11 +377,10 @@ GCM registration process.

      String msg = ""; try { Bundle data = new Bundle(); - // data is a key-value pair. - data.putString("hello", "world"); + data.putString("hello", "World"); String id = Integer.toString(msgId.incrementAndGet()); - gcm.send(GCM_SENDER_ID + "@gcm.googleapis.com", id, data); - msg = "Sending message"; + gcm.send(SENDER_ID + "@gcm.googleapis.com", id, data); + msg = "Sent message"; } catch (IOException ex) { msg = "Error :" + ex.getMessage(); } @@ -278,23 +389,25 @@ GCM registration process.

      @Override protected void onPostExecute(String msg) { - // Displays the text "Sending message" mDisplay.append(msg + "\n"); } }.execute(null, null, null); - } + } else if (view == findViewById(R.id.clear)) { + mDisplay.setText(""); + } }

      As described above in Step 1, the app includes a broadcast receiver for the com.google.android.c2dm.intent.RECEIVE intent. This is the mechanism GCM uses to deliver messages. When {@code onClick()} calls {@code gcm.send()}, it triggers the broadcast receiver's {@code onReceive()} method, which has the responsibility of handling the GCM message. In this sample the receiver's {@code onReceive()} method calls {@code sendNotification()} to put the message into a notification:

      -
      public class GcmBroadcastReceiver extends BroadcastReceiver {
      +
      /**
      + * Handling of GCM messages.
      + */
      +public class GcmBroadcastReceiver extends BroadcastReceiver {
           static final String TAG = "GCMDemo";
           public static final int NOTIFICATION_ID = 1;
           private NotificationManager mNotificationManager;
           NotificationCompat.Builder builder;
           Context ctx;
      -    
      -
           @Override
           public void onReceive(Context context, Intent intent) {
               GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(context);
      @@ -303,7 +416,7 @@ GCM registration process.

      if (GoogleCloudMessaging.MESSAGE_TYPE_SEND_ERROR.equals(messageType)) { sendNotification("Send error: " + intent.getExtras().toString()); } else if (GoogleCloudMessaging.MESSAGE_TYPE_DELETED.equals(messageType)) { - sendNotification("Deleted messages on server: " + + sendNotification("Deleted messages on server: " + intent.getExtras().toString()); } else { sendNotification("Received: " + intent.getExtras().toString()); @@ -313,21 +426,98 @@ GCM registration process.

      // Put the GCM message into a notification and post it. private void sendNotification(String msg) { - mNotificationManager = (NotificationManager) - ctx.getSystemService(Context.NOTIFICATION_SERVICE); - - PendingIntent contentIntent = PendingIntent.getActivity(ctx, 0, - new Intent(ctx, DemoActivity.class), 0); - - NotificationCompat.Builder mBuilder = - new NotificationCompat.Builder(ctx) - .setSmallIcon(R.drawable.ic_stat_notification) - .setContentTitle("GCM Notification") - .setStyle(new NotificationCompat.BigTextStyle() - .bigText(msg)) - .setContentText(msg); - - mBuilder.setContentIntent(contentIntent); - mNotificationManager.notify(NOTIFICATION_ID, mBuilder.build()); + mNotificationManager = (NotificationManager) + ctx.getSystemService(Context.NOTIFICATION_SERVICE); + + PendingIntent contentIntent = PendingIntent.getActivity(ctx, 0, + new Intent(ctx, DemoActivity.class), 0); + + NotificationCompat.Builder mBuilder = + new NotificationCompat.Builder(ctx) + .setSmallIcon(R.drawable.ic_stat_gcm) + .setContentTitle("GCM Notification") + .setStyle(new NotificationCompat.BigTextStyle() + .bigText(msg)) + .setContentText(msg); + + mBuilder.setContentIntent(contentIntent); + mNotificationManager.notify(NOTIFICATION_ID, mBuilder.build()); } }
      + +

      Writing the Server Code

      + +

      Here is an example of a CCS server written in Python. You can use this in conjunction with the sample client code shown above. This sample echo server sends an initial message, and for every upstream message received, it sends a dummy response back to the application that sent the upstream message. This example illustrates how to connect, +send, and receive GCM messages using XMPP. It shouldn't be used as-is +on a production deployment. For examples of HTTP-based servers, see GCM Server.

      + +
      +#!/usr/bin/python
      +import sys, json, xmpp, random, string
      +
      +SERVER = 'gcm.googleapis.com'
      +PORT = 5235
      +USERNAME = ''
      +PASSWORD = ''
      +REGISTRATION_ID = ''
      +
      +unacked_messages_quota = 1000
      +send_queue = []
      +
      +# Return a random alphanumerical id
      +def random_id():
      +  rid = ''
      +  for x in range(8): rid += random.choice(string.ascii_letters + string.digits)
      +  return rid
      +
      +def message_callback(session, message):
      +  global unacked_messages_quota
      +  gcm = message.getTags('gcm')
      +  if gcm:
      +    gcm_json = gcm[0].getData()
      +    msg = json.loads(gcm_json)
      +    if not msg.has_key('message_type'):
      +      # Acknowledge the incoming message immediately.
      +      send({'to': msg['from'],
      +            'message_type': 'ack',
      +            'message_id': msg['message_id']})
      +      # Queue a response back to the server.
      +      if msg.has_key('from'):
      +        # Send a dummy echo response back to the app that sent the upstream message.
      +        send_queue.append({'to': msg['from'],
      +                           'message_id': random_id(),
      +                           'data': {'pong': 1}})
      +    elif msg['message_type'] == 'ack' or msg['message_type'] == 'nack':
      +      unacked_messages_quota += 1
      +
      +def send(json_dict):
      +  template = ("<message><gcm xmlns='google:mobile:data'>{1}</gcm></message>")
      +  client.send(xmpp.protocol.Message(
      +      node=template.format(client.Bind.bound[0], json.dumps(json_dict))))
      +
      +def flush_queued_messages():
      +  global unacked_messages_quota
      +  while len(send_queue) and unacked_messages_quota > 0:
      +    send(send_queue.pop(0))
      +    unacked_messages_quota -= 1
      +
      +client = xmpp.Client('gcm.googleapis.com', debug=['socket'])
      +client.connect(server=(SERVER,PORT), secure=1, use_srv=False)
      +auth = client.auth(USERNAME, PASSWORD)
      +if not auth:
      +  print 'Authentication failed!'
      +  sys.exit(1)
      +
      +client.RegisterHandler('message', message_callback)
      +
      +send_queue.append({'to': REGISTRATION_ID,
      +                   'message_id': 'reg_id',
      +                   'data': {'message_destination': 'RegId',
      +                            'message_id': random_id()}})
      +
      +while True:
      +  client.Process(1)
      +  flush_queued_messages()
      + + + diff --git a/docs/html/google/gcm/helper.jd b/docs/html/google/gcm/helper.jd index bde2df0..e7f2f73 100644 --- a/docs/html/google/gcm/helper.jd +++ b/docs/html/google/gcm/helper.jd @@ -2,6 +2,23 @@ page.title=Using the GCM Helper Libraries page.tags="cloud","push","messaging" @jd:body + + + +
      +

      The information in this document has been superseded by GCM Server and GCM Client. Please use the {@code GoogleCloudMessaging} API instead of the GCM client helper library. The GCM server helper library is still valid.

      + + +
      +
      + +
      diff --git a/docs/html/google/gcm/index.jd b/docs/html/google/gcm/index.jd index f9c3ed3..fcb0a58 100644 --- a/docs/html/google/gcm/index.jd +++ b/docs/html/google/gcm/index.jd @@ -48,6 +48,9 @@ up to 4kb of payload data (so apps like instant messaging can consume the messag

      Seamless multi-device messaging

      Maps a single user to a notification key, which you can then use to send a single message to multiple devices owned by the user. Use this form to sign up for User Notifications. Learn more »

      + +

      Get Started

      +

      Get started using the new features with a tutorial that walks you through creating a GCM app. Learn more »

      diff --git a/docs/html/google/gcm/notifications.jd b/docs/html/google/gcm/notifications.jd index 6a4b34a..df171cf 100644 --- a/docs/html/google/gcm/notifications.jd +++ b/docs/html/google/gcm/notifications.jd @@ -52,6 +52,9 @@ page.title=User Notifications

      The way this works is that during registration, the 3rd-party server requests a {@code notification_key}. The {@code notification_key} maps a particular user to all of the user's associated registration IDs (a regID represents a particular Android application running on a particular device). Then instead of sending one message to one regID at a time, the 3rd-party server can send a message to to the {@code notification_key}, which then sends the message to all of the user's regIDs.

      +

      Note: A notification dismissal message is like any other upstream message, meaning that it will be delivered to the other devices that belong to the specified {@code notification_key}. You should design your app to handle cases where the app receives a dismissal message, but has not yet displayed the notification that is being dismissed. You can solve this by caching the dismissal and then reconciling it with the corresponding notification. +

      +

      You can use this feature with either the new GCM Cloud Connection Server (CCS), or the older GCM HTTP server.

      diff --git a/docs/html/google/gcm/server.jd b/docs/html/google/gcm/server.jd new file mode 100644 index 0000000..92a1531 --- /dev/null +++ b/docs/html/google/gcm/server.jd @@ -0,0 +1,160 @@ +page.title=GCM Server +@jd:body + +
      +
      + +

      Quickview

      + + + + +

      In this document

      + +
        +
      1. Requirements
      2. +
      3. Setting Up GCM
      4. +
      5. Setting Up an HTTP Server +
          +
        1. Using a standard web server
        2. +
        3. Using App Engine for Java
        4. +
        +
      6. +
      + +

      See Also

      + +
        +
      1. Getting Started
      2. +
      3. GCM Client
      4. +
      5. Cloud Connection Server
      6. + + +
      + +
      +
      + + + + +

      This document gives examples of GCM server-side code for HTTP. For an example of an XMPP server (Cloud Connection Server), see Getting Started. Note that a full GCM implementation requires a client-side implementation, in addition to the server. For a complete working example that includes client and server-side code, see Getting Started. + +

      Requirements

      +

      For the web server:

      +
        +
      • Ant 1.8 (it might work with earlier versions, but it's not guaranteed).
      • +
      • One of the following: + +
      • +
      • A Google account registered to use GCM.
      • +
      • The API key for that account.
      • +
      +

      For the Android application:

      +
        +
      • Emulator (or device) running Android 2.2 with Google APIs.
      • +
      • The Google API project number of the account registered to use GCM.
      • +
      +

      Setting Up GCM

      +

      Before proceeding with the server and client setup, it's necessary to register a Google account with the Google API Console, enable Google Cloud Messaging in GCM, and obtain an API key from the Google API Console.

      +

      For instructions on how to set up GCM, see Getting Started.

      + + +

      Setting Up an HTTP Server

      +

      This section describes the different options for setting up an HTTP server.

      +

      Using a standard web server

      +

      To set up the server using a standard, servlet-compliant web server:

      +
        +
      1. From the open source site, download the following directories: gcm-server, samples/gcm-demo-server, and samples/gcm-demo-appengine.

        + + +
      2. In a text editor, edit the samples/gcm-demo-server/WebContent/WEB-INF/classes/api.key and replace the existing text with the API key obtained above.
      3. +
      4. In a shell window, go to the samples/gcm-demo-server directory.
      5. +
      6. Generate the server's WAR file by running ant war:
      7. + +
        $ ant war
        +
        +Buildfile:build.xml
        +
        +init:
        +   [mkdir] Created dir: build/classes
        +   [mkdir] Created dir: dist
        +
        +compile:
        +   [javac] Compiling 6 source files to build/classes
        +
        +war:
        +     [war] Building war: dist/gcm-demo.war
        +
        +BUILD SUCCESSFUL
        +Total time: 0 seconds
        +
        + +
      8. Deploy the dist/gcm-demo.war to your running server. For instance, if you're using Jetty, copy gcm-demo.war to the webapps directory of the Jetty installation.
      9. +
      10. Open the server's main page in a browser. The URL depends on the server you're using and your machine's IP address, but it will be something like http://192.168.1.10:8080/gcm-demo/home, where gcm-demo is the application context and /home is the path of the main servlet. + +
      11. +
      +

      Note: You can get the IP by running ifconfig on Linux or MacOS, or ipconfig on Windows.

      + +

      You server is now ready.

      + +

      Using App Engine for Java

      + +

      To set up the server using a standard App Engine for Java:

      +
        +
      1. Get the files from the open source site, as described above.

        +
      2. +
      3. In a text editor, edit samples/gcm-demo-appengine/src/com/google/android/gcm/demo/server/ApiKeyInitializer.java and replace the existing text with the API key obtained above. + +

        Note: The API key value set in that class will be used just once to create a persistent entity on App Engine. If you deploy the application, you can use App Engine's Datastore Viewer to change it later.

        + +
      4. +
      5. In a shell window, go to the samples/gcm-demo-appengine directory.
      6. +
      7. Start the development App Engine server by ant runserver, using the -Dsdk.dir to indicate the location of the App Engine SDK and -Dserver.host to set your server's hostname or IP address:
      8. + +
        +$ ant -Dsdk.dir=/opt/google/appengine-java-sdk runserver -Dserver.host=192.168.1.10
        +Buildfile: gcm-demo-appengine/build.xml
        +
        +init:
        +    [mkdir] Created dir: gcm-demo-appengine/dist
        +
        +copyjars:
        +
        +compile:
        +
        +datanucleusenhance:
        +  [enhance] DataNucleus Enhancer (version 1.1.4) : Enhancement of classes
        +  [enhance] DataNucleus Enhancer completed with success for 0 classes. Timings : input=28 ms, enhance=0 ms, total=28 ms. Consult the log for full details
        +  [enhance] DataNucleus Enhancer completed and no classes were enhanced. Consult the log for full details
        +
        +runserver:
        +     [java] Jun 15, 2012 8:46:06 PM com.google.apphosting.utils.jetty.JettyLogger info
        +     [java] INFO: Logging to JettyLogger(null) via com.google.apphosting.utils.jetty.JettyLogger
        +     [java] Jun 15, 2012 8:46:06 PM com.google.apphosting.utils.config.AppEngineWebXmlReader readAppEngineWebXml
        +     [java] INFO: Successfully processed gcm-demo-appengine/WebContent/WEB-INF/appengine-web.xml
        +     [java] Jun 15, 2012 8:46:06 PM com.google.apphosting.utils.config.AbstractConfigXmlReader readConfigXml
        +     [java] INFO: Successfully processed gcm-demo-appengine/WebContent/WEB-INF/web.xml
        +     [java] Jun 15, 2012 8:46:09 PM com.google.android.gcm.demo.server.ApiKeyInitializer contextInitialized
        +     [java] SEVERE: Created fake key. Please go to App Engine admin console, change its value to your API Key (the entity type is 'Settings' and its field to be changed is 'ApiKey'), then restart the server!
        +     [java] Jun 15, 2012 8:46:09 PM com.google.appengine.tools.development.DevAppServerImpl start
        +     [java] INFO: The server is running at http://192.168.1.10:8080/
        +     [java] Jun 15, 2012 8:46:09 PM com.google.appengine.tools.development.DevAppServerImpl start
        +     [java] INFO: The admin console is running at http://192.168.1.10:8080/_ah/admin
        +
        + +
      9. Open the server's main page in a browser. The URL depends on the server you're using and your machine's IP address, but it will be something like http://192.168.1.10:8080/home, where /home is the path of the main servlet.
      10. + +

        Note: You can get the IP by running ifconfig on Linux or MacOS, or ipconfig on Windows.

        + +
      +

      You server is now ready.

      + + diff --git a/docs/html/google/google_toc.cs b/docs/html/google/google_toc.cs index 13d3eb3..891819b 100644 --- a/docs/html/google/google_toc.cs +++ b/docs/html/google/google_toc.cs @@ -132,11 +132,11 @@
    • User Notifications
    • -
    • - Demo App Tutorial +
    • + GCM Client
    • -
    • - Using the Helper Libraries +
    • + GCM Server
    • Advanced Topics diff --git a/docs/html/reference/com/google/android/gcm/GCMBaseIntentService.html b/docs/html/reference/com/google/android/gcm/GCMBaseIntentService.html index b230b88..ad50a35 100644 --- a/docs/html/reference/com/google/android/gcm/GCMBaseIntentService.html +++ b/docs/html/reference/com/google/android/gcm/GCMBaseIntentService.html @@ -838,6 +838,9 @@ Summary:

      Class Overview

      +
      DEPRECATED. Please use the GoogleCloudMessaging API instead.
      +

      Skeleton for application-specific IntentServices responsible for handling communication from Google Cloud Messaging service.

      diff --git a/docs/html/reference/com/google/android/gcm/GCMBroadcastReceiver.html b/docs/html/reference/com/google/android/gcm/GCMBroadcastReceiver.html index 91c0994..ea36df4 100644 --- a/docs/html/reference/com/google/android/gcm/GCMBroadcastReceiver.html +++ b/docs/html/reference/com/google/android/gcm/GCMBroadcastReceiver.html @@ -737,6 +737,10 @@ Summary:

      Class Overview

      + +
      DEPRECATED. Please use the GoogleCloudMessaging API instead.
      +

      BroadcastReceiver that receives GCM messages and delivers them to an application-specific GCMBaseIntentService subclass.

      diff --git a/docs/html/reference/com/google/android/gcm/GCMConstants.html b/docs/html/reference/com/google/android/gcm/GCMConstants.html index cb260e0..8b782b6 100644 --- a/docs/html/reference/com/google/android/gcm/GCMConstants.html +++ b/docs/html/reference/com/google/android/gcm/GCMConstants.html @@ -710,6 +710,8 @@ Summary:

      Class Overview

      +
      DEPRECATED. Please use the GoogleCloudMessaging API instead.

      Constants used by the GCM library.

      diff --git a/docs/html/reference/com/google/android/gcm/GCMRegistrar.html b/docs/html/reference/com/google/android/gcm/GCMRegistrar.html index 545abe2..21a990f 100644 --- a/docs/html/reference/com/google/android/gcm/GCMRegistrar.html +++ b/docs/html/reference/com/google/android/gcm/GCMRegistrar.html @@ -713,6 +713,10 @@ Summary:

      Class Overview

      + +
      DEPRECATED. Please use the GoogleCloudMessaging API instead.
      +

      Utilities for device registration.

      Note: this class uses a private SharedPreferences diff --git a/docs/html/reference/com/google/android/gcm/package-summary.html b/docs/html/reference/com/google/android/gcm/package-summary.html index d2b05e6..6c8a993 100644 --- a/docs/html/reference/com/google/android/gcm/package-summary.html +++ b/docs/html/reference/com/google/android/gcm/package-summary.html @@ -642,21 +642,19 @@ onkeyup="return search_changed(event, false, '/')" /> - + - + - + - +
      GCMBaseIntentServiceSkeleton for application-specific IntentServices responsible for - handling communication from Google Cloud Messaging service. DEPRECATED. 
      GCMBroadcastReceiverBroadcastReceiver that receives GCM messages and delivers them to - an application-specific GCMBaseIntentService subclass. DEPRECATED. 
      GCMConstantsConstants used by the GCM library. DEPRECATED. 
      GCMRegistrarUtilities for device registration. DEPRECATED. 

    diff --git a/docs/html/reference/gcm-packages.html b/docs/html/reference/gcm-packages.html index 8065be9..2b5dc2d 100644 --- a/docs/html/reference/gcm-packages.html +++ b/docs/html/reference/gcm-packages.html @@ -623,14 +623,15 @@ onkeyup="return search_changed(event, false, '/')" /> com.google.android.gcm - + DEPRECATED. Please use the GoogleCloudMessaging API instead of this client helper library. See GCM Client for more information. com.google.android.gcm.server - + Helper library for GCM HTTP server operations. See GCM Server for more information. -- cgit v1.1