diff --git a/docs/html/guide/google/gcm/adv.jd b/docs/html/guide/google/gcm/adv.jd new file mode 100644 index 0000000000000..aec8ca48736c6 --- /dev/null +++ b/docs/html/guide/google/gcm/adv.jd @@ -0,0 +1,255 @@ +page.title=GCM Advanced Topics +@jd:body + +
+
+ +

Quickview

+ + + + +

In this document

+ +
    +
  1. Lifetime of a Message
  2. +
  3. Throttling
  4. +
  5. Keeping the Registration State in Sync +
      +
    1. Canonical IDs
    2. +
    +
  6. +
  7. Automatic Retry Using Exponential Back-Off
  8. +
  9. How Unregistration Works
  10. +
  11. Send-to-Sync vs. Messages with Payload +
      +
    1. Send-to-sync messages
    2. +
    3. Messages with payload
    4. +
    +
  12. +
  13. Setting an Expiration Date for a Message
  14. +
  15. Receiving Messages from Multiple Senders
  16. +
+ +
+
+

This document covers advanced topics for GCM.

+ + + + +

Lifetime of a Message

+

When a 3rd-party server posts a message to GCM and receives a message ID back, it does not mean that the message was already delivered to the device. Rather, it means that it was accepted for delivery. What happens to the message after it is accepted depends on many factors.

+

In the best-case scenario, if the device is connected to GCM, the screen is on, and there are no throttling restrictions (see Throttling), the message will be delivered right away.

+

If the device is connected but idle, the message will still be +delivered right away unless the delay_while_idle flag is set to true. Otherwise, it will be stored in the GCM servers until the device is awake. And that's where the collapse_key flag plays a role: if there is already a message with the same collapse key (and registration ID) stored and waiting for delivery, the old message will be discarded and the new message will take its place (that is, the old message will be collapsed by the new one). However, if the collapse key is not set, both the new and old messages are stored for future delivery.

+ +

Note: There is a limit on how many messages can be stored without collapsing. That limit is currently 100. If the limit is reached, all stored messages are discarded. Then when the device is back online, it receives a special message indicating that the limit was reached. The application can then handle the situation properly, typically by requesting a full sync.

+ +

If the device is not connected to GCM, the message will be stored until a connection is established (again respecting the collapse key rules). When a connection is established, GCM will deliver all pending messages to the device, regardless of the delay_while_idle flag. If the device never gets connected again (for instance, if it was factory reset), the message will eventually time out and be discarded from GCM storage. The default timeout is 4 weeks, unless the time_to_live flag is set.

+ +

Note: When you set the time_to_live flag, you must also set collapse_key. Otherwise the message will be rejected as a bad request.

+

Finally, when GCM attempts to deliver a message to the device and the application was uninstalled, GCM will discard that message right away and invalidate the registration ID. Future attempts to send a message to that device will get a NotRegistered error. See How Unregistration Works for more information.

+

Although is not possible to track the status of each individual message, the Google APIs Console stats are broken down by messages sent to device, messages collapsed, and messages waiting for delivery.

+ +

Throttling

+

To prevent abuse (such as sending a flood of messages to a device) and +to optimize for the overall network efficiency and battery life of +devices, GCM implements throttling of messages using a token bucket +scheme. Messages are throttled on a per application and per collapse +key basis (including non-collapsible messages). Each application +collapse key is granted some initial tokens, and new tokens are granted +periodically therefter. Each token is valid for a single message sent to +the device. If an application collapse key exhausts its supply of +available tokens, new messages are buffered in a pending queue until +new tokens become available at the time of the periodic grant. Thus +throttling in between periodic grant intervals may add to the latency +of message delivery for an application collapse key that sends a large +number of messages within a short period of time. Messages in the pending +queue of an application collapse key may be delivered before the time +of the next periodic grant, if they are piggybacked with messages +belonging to a non-throttled category by GCM for network and battery +efficiency reasons.

+ +

Keeping the Registration State in Sync

+

Whenever the application receives a com.google.android.c2dm.intent.REGISTRATION intent with a registration_id extra, it should save the ID for future use, pass it to the 3rd-party server to complete the registration, and keep track of whether the server completed the registration. If the server fails to complete the registration, it should try again or unregister from GCM.

+

There are also two other scenarios that require special care:

+ +

When an application is updated, it should invalidate its existing registration ID, as it is not guaranteed to work with the new version. Because there is no lifecycle method called when the application is updated, the best way to achieve this validation is by storing the current application version when a registration ID is stored. Then when the application is started, compare the stored value with the current application version. If they do not match, invalidate the stored data and start the registration process again.

+ +

Similarly, you should not save the registration ID when an application is backed up. This is because the registration ID could become invalid by the time the application is restored, which would put the application in an invalid state (that is, the application thinks it is registered, but the server and GCM do not store that registration ID anymore—thus the application will not get more messages).

+

Canonical IDs

+

On the server side, as long as the application is behaving well, everything should work normally. However, if a bug in the application triggers multiple registrations for the same device, it can be hard to reconcile state and you might end up with duplicate messages.

+

GCM provides a facility called "canonical registration IDs" to easily recover from these situations. A canonical registration ID is defined to be the ID of the last registration requested by your application. This is the ID that the server should use when sending messages to the device.

+

If later on you try to send a message using a different registration ID, GCM will process the request as usual, but it will include the canonical registration ID in the registration_id field of the response. Make sure to replace the registration ID stored in your server with this canonical ID, as eventually the ID you're using will stop working.

+ +

Automatic Retry Using Exponential Back-Off

+ +

When the application receives a com.google.android.c2dm.intent.REGISTRATION intent with the error extra set as SERVICE_NOT_AVAILABLE, it should retry the failed operation (register or unregister).

+

In the simplest case, if your application just calls register and GCM is not a fundamental part of the application, the application could simply ignore the error and try to register again the next time it starts. Otherwise, it should retry the previous operation using exponential back-off. In exponential back-off, each time there is a failure, it should wait twice the previous amount of time before trying again. If the register (or unregister) operation was synchronous, it could be retried in a simple loop. However, since it is asynchronous, the best approach is to schedule a pending intent to retry the operation. The following steps describe how to implement this in the MyIntentService example used above:

+
    +
  1. Create a random token to verify the origin of the retry intent: + +
    private static final String TOKEN =
    +        Long.toBinaryString(new Random().nextLong());
    +
    + +
  2. Change the handleRegistration() method so it creates the pending intent when appropriate:
  3. + +
    ...
    +if (error != null) {
    + if ("SERVICE_NOT_AVAILABLE".equals(error)) {
    +   long backoffTimeMs = // get back-off time from shared preferences
    +   long nextAttempt = SystemClock.elapsedRealtime() + backoffTimeMs;
    +   Intent retryIntent = new Intent("com.example.gcm.intent.RETRY");
    +   retryIntent.putExtra("token", TOKEN);
    +   PendingIntent retryPendingIntent =
    +       PendingIntent.getBroadcast(context, 0, retryIntent, 0);
    +   AlarmManager am = (AlarmManager)   
    +       context.getSystemService(Context.ALARM_SERVICE);
    +   am.set(AlarmManager.ELAPSED_REALTIME, nextAttempt, retryPendingIntent);
    +   backoffTimeMs *= 2; // Next retry should wait longer.
    +   // update back-off time on shared preferences
    + } else {
    +   // Unrecoverable error, log it
    +   Log.i(TAG, "Received error: " + error);
    +}
    +...
    +

    The back-off time is stored in a shared preference. This ensures that it is persistent across multiple activity launches. The name of the intent does not matter, as long as the same intent is used in the following steps.

    + +
  4. Change the onHandleIntent() method adding an else if case for the retry intent:
  5. + +
    ...
    +} else if (action.equals("com.example.gcm.intent.RETRY")) {
    +    String token = intent.getStringExtra("token");
    +    // make sure intent was generated by this class, not by a malicious app
    +    if (TOKEN.equals(token)) {
    +        String registrationId = // get from shared properties
    +        if (registrationId != null) {
    +        // last operation was attempt to unregister; send UNREGISTER intent again
    +    } else {
    +        // last operation was attempt to register; send REGISTER intent again
    +    }
    +}
    +...
    + +
  6. Create a new instance of MyReceiver in your activity:
  7. + +
    private final MyBroadcastReceiver mRetryReceiver = new MyBroadcastReceiver();
    +
    + +
  8. In the activity's onCreate() method, register the new instance to receive the com.example.gcm.intent.RETRY intent: +
    ...
    +IntentFilter filter = new IntentFilter("com.example.gcm.intent.RETRY");
    +filter.addCategory(getPackageName());
    +registerReceiver(mRetryReceiver, filter);
    +...
    + +

    Note: You must dynamically create a new instance of the broadcast receiver since the one defined by the manifest can only receive intents with the com.google.android.c2dm.permission.SEND permission. The permission com.google.android.c2dm.permission.SEND is a system permission and as such it cannot be granted to a regular application.

    + +
  9. + +
  10. In the activity's onDestroy() method, unregister the broadcast receiver:
  11. + +
    unregisterReceiver(mRetryReceiver);
    +
+

How Unregistration Works

+

There are two ways to unregister a device from GCM: manually and automatically.

+

An Android application can manually unregister itself by issuing a com.google.android.c2dm.intent.UNREGISTER intent, which is useful when the application offers a logoff feature (so it can unregister on logoff and register again on logon). See the Architectural Overview for more discussion of this topic. This is the sequence of events when an application unregisters itself:

+
    +
  1. The application issues a com.google.android.c2dm.intent.UNREGISTER intent, passing the registration ID (the application should have saved its registration ID when it received the proper com.google.android.c2dm.intent.REGISTRATION intent).
  2. +
  3. When the GCM server is done with the unregistration, it sends a com.google.android.c2dm.intent.REGISTRATION intent with the unregistered extra set.
  4. +
  5. The application then must contact the 3rd-party server so it can remove the registration ID.
  6. +
  7. The application should also clear its registration ID. +
  8. +
+

An application can be automatically unregistered after it is uninstalled from the device. However, this process does not happens right away, as Android does not provide an uninstall callback. What happens in this scenario is as follows:

+
    +
  1. The end user uninstalls the application.
  2. +
  3. The 3rd-party server sends a message to GCM server.
  4. +
  5. The GCM server sends the message to the device.
  6. +
  7. The GCM client receives the message and queries Package Manager, which returns a "package not found" error.
  8. +
  9. The GCM client informs the GCM server that the application was uninstalled.
  10. +
  11. The GCM server marks the registration ID for deletion.
  12. +
  13. The 3rd-party server sends a message to GCM.
  14. +
  15. The GCM returns a NotRegistered error message to the 3rd-party server.
  16. +
  17. The 3rd-party deletes the registration ID. +
  18. +
+

Note that it might take a while for the registration ID be completely removed from GCM. Thus it is possible that messages sent during step 7 above gets a valid message ID as response, even though the message will not be delivered to the device. Eventually, the registration ID will be removed and the server will get a NotRegistered error, without any further action being required from the 3rd-party server (this scenario happens frequently while an application is being developed and tested).

+ +

Send-to-Sync vs. Messages with Payload

+

Every message sent in GCM, regardless of its other characteristics, is either a "send-to-sync" (collapsible) message or a "message with payload" (non-collapsible message).

+

Send-to-sync messages

+

A send-to-sync (collapsible) message is typically a "tickle" that tells a mobile application to sync data from the server. For example, suppose you have an email application. When a user receives new email on the server, the server pings the mobile application with a "New mail" message. This tells the application to sync to the server to pick up the new email. The server might send this message multiple times as new mail continues to accumulate, before the application has had a chance to sync. But if the user has received 25 new emails, there's no need to preserve every "New mail" message. One is sufficient. This is a case where you would use the GCM collapse_key parameter. A collapse key is an arbitrary string that is used to collapse a group of like messages when the device is offline, so that only the last message gets sent to the client. For example, "New mail," "Updates available," and so on

+

GCM allows a maximum of 4 different collapse keys to be used by the GCM server at any given time. In other words, the GCM server can simultaneously store 4 different send-to-sync messages, each with a different collapse key.

+

Messages with payload

+

Unlike a send-to-sync message, every "message with payload" (non-collapsible message) is delivered. The payload the message contains can be up to 4K. For example, here is a JSON-formatted message in an IM application in which spectators are discussing a sporting event:

+ +
{
+  "registration_id" : "APA91bHun4MxP5egoKMwt2KZFBaFUH-1RYqx...",
+  "data" : {
+    "Nick" : "Mario",
+    "Text" : "great match!",
+    "Room" : "PortugalVSDenmark",
+  },
+}
+ +

A "message with payload" is not simply a "ping" to the mobile application to contact the server to fetch data. In the aforementioned IM application, for example, you would want to deliver every message, because every message has different content. To specify a non-collapsible message, you simply omit the collapse_key parameter. Thus GCM will send each message individually. Note that the order of delivery is not guaranteed.

+

GCM will store up to 100 non-collapsible messages. After that, all messages are discarded from GCM, and a new message is created that tells the client how far behind it is. The message is delivered through a regular com.google.android.c2dm.intent.RECEIVE intent, with the following extras:

+ +

The application should respond by syncing with the server to recover the discarded messages.

+

Note: If your application does not need to use non-collapsible messages, collapsible messages are a better choice from a performance standpoint, because they put less of a burden on the device battery. + +

+

Setting an Expiration Date for a Message

+

The Time to Live (TTL) feature lets the sender specify the maximum lifespan of a message using the time_to_live parameter in the send request. The value of this parameter must be a duration from 0 to 2,419,200 seconds, and it corresponds to the maximum period of time for which GCM will store and try to deliver the message. Requests that don't contain this field default to the maximum period of 4 weeks.

+

Here are some possible uses for this feature:

+ +

Background

+

GCM will usually deliver messages immediately after they are sent. However, this might not always be possible. For example, the device could be turned off, offline, or otherwise unavailable. In other cases, the sender itself might request that messages not be delivered until the device becomes active by using the delay_while_idle flag. Finally, GCM might intentionally delay messages to prevent an application from consuming excessive resources and negatively impacting battery life.

+

When this happens, GCM will store the message and deliver it as soon as it's feasible. While this is fine in most cases, there are some applications for which a late message might as well never be delivered. For example, if the message is an incoming call or video chat notification, it will only be meaningful for a small period of time before the call is terminated. Or if the message is an invitation to an event, it will be useless if received after the event has ended.

+

Another advantage of specifying the expiration date for a message is that GCM will never throttle messages with a time_to_live value of 0 seconds. In other words, GCM will guarantee best effort for messages that must be delivered "now or never." Keep in mind that a time_to_live value of 0 means messages that can't be delivered immediately will be discarded. However, because such messages are never stored, this provides the best latency for sending notifications.

+

Here is an example of a JSON-formatted request that includes TTL:

+
+{
+  "collapse_key" : "demo",
+  "delay_while_idle" : true,
+  "registration_ids" : ["xyz"],
+  "data" : {
+    "key1" : "value1",
+    "key2" : "value2",
+  },
+  "time_to_live" : 3
+},
+
+ + +

Receiving Messages from Multiple Senders

+

GCM allows multiple parties to send messages to the same application. For example, suppose your application is an articles aggregator with multiple contributors, and you want each of them to be able to send a message when they publish a new article. This message might contain a URL so that the application can download the article. Instead of having to centralize all sending activity in one location, GCM gives you the ability to let each of these contributors send its own messages.

+

To make this possible, all you need to do is have each sender generate its own project ID. Then include those IDs in the sender field, separated by commas, when requesting a registration. Finally, share the registration ID with your partners, and they'll be able to send messages to your application using their own authentication keys.

+

This code snippet illustrates this feature. Senders are passed as an intent extra in a comma-separated list:

+
Intent intent = new Intent(GCMConstants.INTENT_TO_GCM_REGISTRATION);
+intent.setPackage(GSF_PACKAGE);
+intent.putExtra(GCMConstants.EXTRA_APPLICATION_PENDING_INTENT,
+        PendingIntent.getBroadcast(context, 0, new Intent(), 0));
+String senderIds = "968350041068,652183961211";
+intent.putExtra(GCMConstants.EXTRA_SENDER, senderIds);
+ontext.startService(intent);
+ 
+ +

Note that there is limit of 100 multiple senders.

+ diff --git a/docs/html/guide/google/gcm/c2dm.jd b/docs/html/guide/google/gcm/c2dm.jd new file mode 100644 index 0000000000000..fd1bb0c5a6dff --- /dev/null +++ b/docs/html/guide/google/gcm/c2dm.jd @@ -0,0 +1,107 @@ +page.title=Migration +@jd:body + +
+
+ +

Quickview

+ + + + +

In this document

+ +
    +
  1. Historical Overview
  2. +
  3. How is GCM Different from C2DM?
  4. +
  5. Migrating Your Apps +
      +
    1. Client changes
    2. +
    3. Server changes
    4. +
    +
  6. +
+ +
+
+ +

Android Cloud to Device Messaging (C2DM) is deprecated. The C2DM service will continue to be maintained in the short term, but C2DM will accept no new users, and it will grant no new quotas. C2DM developers are strongly encouraged to move to Google Cloud Messaging (GCM). GCM is the next generation of C2DM.

+

This document is addressed to C2DM developers who are moving to GCM. It describes the differences between GCM and C2DM, and explains how to migrate existing C2DM apps to GCM.

+ + +

Historical Overview

+

C2DM was launched in 2010 to help Android apps send data from servers to their applications. Servers can tell apps to contact the server directly, to fetch updated application or user data. The C2DM service handles all aspects of queueing of messages and delivery to the target application running on the target device.

+

GCM replaces C2DM. The focus of GCM is as follows:

+ +

How is GCM Different from C2DM?

+

GCM builds on the core foundation of C2DM. Here is what's different:

+ +
+
Simple API Key
+
To use the GCM service, you need to obtain a Simple API Key from Google APIs console page. For more information, see Getting Started. Note that GCM only accepts Simple API Key—using ClientLogin or OAuth2 tokens will not work. +
+
Sender ID
+
In C2DM, the Sender ID is an email address. In GCM, the Sender ID is a project ID that you acquire from the API console, as described in Getting Started.
+ +
JSON format
+
GCM HTTP requests support JSON format in addition to plain text. For more information, see the Architectural Overview.
+ +
Multicast messages
+
In GCM you can send the same message to multiple devices simultaneously. For example, a sports app wanting to deliver a score update to fans can now send the message to up to 1000 registration IDs in the same request (requires JSON). For more information, see the Architectural Overview.
+ +
Multiple senders
+
Multiple parties can send messages to the same app with one common registration ID. For more information, see Advanced Topics.
+ +
Time-to-live messages
+
Apps like video chat and calendar apps can send expiring invitation events with a time-to-live value between 0 and 4 weeks. GCM will store the messages until they expire. A message with a time-to-live value of 0 will not be stored on the GCM server, nor will it be throttled. For more information, see Advanced Topics.
+ +
Messages with payload
+
Apps can use "messages with payload" to deliver messages of up to 4 Kb. This would be useful in a chat application, for example. To use this feature, simply omit the collapse_key parameter and messages will not be collapsed. GCM will store up to 100 messages. If you exceed that number, all messages will be discarded but you will receive a special message. If an application receives this message, it needs to sync with the server. For more information, see Advanced Topics.
+ +
Canonical registration ID
+
There may be situations where the server ends up with 2 registration IDs for the same device. If the GCM response contains a registration ID, simply replace the registration ID you have with the one provided. With this feature your application doesn't need to send the device ID to your server anymore. For more information, see Advanced Topics.
+
+

GCM also provides helper libraries (client and server) to make writing your code easier.

+

Migrating Your Apps

+

This section describes how to move existing C2DM apps to GCM.

+

Client changes

+

Migration is simple! The only change required in the application is replacing the email account passed in the sender parameter of the registration intent with the project ID generated when signing up for the new service. 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);
+

After receiving a response from GCM, the registration ID obtained must be sent to the application server. When doing this, the application should indicate that it is sending a GCM registration ID so that the server can distinguish it from existing C2DM registrations.

+

Server changes

+

When the application server receives a GCM registration ID, it should store it and mark it as such.

+

Sending messages to GCM devices requires a few changes:

+ +

For example: +

+
Content-Type:application/json
+Authorization:key=AIzaSyB-1uEai2WiUapxCs2Q0GZYzPu7Udno5aA
+
+{
+  "registration_id" : "APA91bHun4MxP5egoKMwt2KZFBaFUH-1RYqx...",
+  "data" : {
+    "Team" : "Portugal",
+    "Score" : "3",
+    "Player" : "Varela",
+  },
+}
+

For a detailed discussion of this topic and more examples, see the Architectural Overview.

+

Eventually, once enough users of your application have migrated to the new service, you might want to take advantage of the new JSON-formatted requests that give access to the full set of features provided by GCM.

+ diff --git a/docs/html/guide/google/gcm/client-javadoc/allclasses-frame.html b/docs/html/guide/google/gcm/client-javadoc/allclasses-frame.html new file mode 100644 index 0000000000000..4788142af7689 --- /dev/null +++ b/docs/html/guide/google/gcm/client-javadoc/allclasses-frame.html @@ -0,0 +1,37 @@ + + + + + + +All Classes + + + + + + + + + + + +All Classes +
+ + + + + +
GCMBaseIntentService +
+GCMBroadcastReceiver +
+GCMConstants +
+GCMRegistrar +
+
+ + + diff --git a/docs/html/guide/google/gcm/client-javadoc/allclasses-noframe.html b/docs/html/guide/google/gcm/client-javadoc/allclasses-noframe.html new file mode 100644 index 0000000000000..cf3b68c157039 --- /dev/null +++ b/docs/html/guide/google/gcm/client-javadoc/allclasses-noframe.html @@ -0,0 +1,37 @@ + + + + + + +All Classes + + + + + + + + + + + +All Classes +
+ + + + + +
GCMBaseIntentService +
+GCMBroadcastReceiver +
+GCMConstants +
+GCMRegistrar +
+
+ + + diff --git a/docs/html/guide/google/gcm/client-javadoc/com/google/android/gcm/GCMBaseIntentService.html b/docs/html/guide/google/gcm/client-javadoc/com/google/android/gcm/GCMBaseIntentService.html new file mode 100644 index 0000000000000..0b2cfad71a84e --- /dev/null +++ b/docs/html/guide/google/gcm/client-javadoc/com/google/android/gcm/GCMBaseIntentService.html @@ -0,0 +1,446 @@ + + + + + + +GCMBaseIntentService + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +com.google.android.gcm +
+Class GCMBaseIntentService

+
+java.lang.Object
+  extended by IntentService
+      extended by com.google.android.gcm.GCMBaseIntentService
+
+
+
+
public abstract class GCMBaseIntentService
extends IntentService
+ + +

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

+ The abstract methods in this class are called from its worker thread, and + hence should run in a limited amount of time. If they execute long + operations, they should spawn new threads, otherwise the worker thread will + be blocked. +

+ +

+


+ +

+ + + + + + + + + + + +
+Field Summary
+static java.lang.StringTAG + +
+           
+  + + + + + + + + + + + +
+Constructor Summary
+protected GCMBaseIntentService(java.lang.String senderId) + +
+          Subclasses must create a public no-arg constructor and pass the + sender id to be used for registration.
+  + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Method Summary
+protected  voidonDeletedMessages(Context context, + int total) + +
+          Called when the GCM server tells pending messages have been deleted + because the device was idle.
+protected abstract  voidonError(Context context, + java.lang.String errorId) + +
+          Called on registration or unregistration error.
+ voidonHandleIntent(Intent intent) + +
+           
+protected abstract  voidonMessage(Context context, + Intent intent) + +
+          Called when a cloud message has been received.
+protected  booleanonRecoverableError(Context context, + java.lang.String errorId) + +
+          Called on a registration error that could be retried.
+protected abstract  voidonRegistered(Context context, + java.lang.String registrationId) + +
+          Called after a device has been registered.
+protected abstract  voidonUnregistered(Context context, + java.lang.String registrationId) + +
+          Called after a device has been unregistered.
+  + + + + + + + +
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
+  +

+ + + + + + + + +
+Field Detail
+ +

+TAG

+
+public static final java.lang.String TAG
+
+
+
See Also:
Constant Field Values
+
+ + + + + + + + +
+Constructor Detail
+ +

+GCMBaseIntentService

+
+protected GCMBaseIntentService(java.lang.String senderId)
+
+
Subclasses must create a public no-arg constructor and pass the + sender id to be used for registration. +

+

+ + + + + + + + +
+Method Detail
+ +

+onMessage

+
+protected abstract void onMessage(Context context,
+                                  Intent intent)
+
+
Called when a cloud message has been received. +

+

+
Parameters:
context - application's context.
intent - intent containing the message payload as extras.
+
+
+
+ +

+onDeletedMessages

+
+protected void onDeletedMessages(Context context,
+                                 int total)
+
+
Called when the GCM server tells pending messages have been deleted + because the device was idle. +

+

+
Parameters:
context - application's context.
total - total number of collapsed messages
+
+
+
+ +

+onRecoverableError

+
+protected boolean onRecoverableError(Context context,
+                                     java.lang.String errorId)
+
+
Called on a registration error that could be retried. + +

By default, it does nothing and returns true, but could be + overridden to change that behavior and/or display the error. +

+

+
Parameters:
context - application's context.
errorId - error id returned by the GCM service. +
Returns:
if true, failed operation will be retried (using + exponential backoff).
+
+
+
+ +

+onError

+
+protected abstract void onError(Context context,
+                                java.lang.String errorId)
+
+
Called on registration or unregistration error. +

+

+
Parameters:
context - application's context.
errorId - error id returned by the GCM service.
+
+
+
+ +

+onRegistered

+
+protected abstract void onRegistered(Context context,
+                                     java.lang.String registrationId)
+
+
Called after a device has been registered. +

+

+
Parameters:
context - application's context.
registrationId - the registration id returned by the GCM service.
+
+
+
+ +

+onUnregistered

+
+protected abstract void onUnregistered(Context context,
+                                       java.lang.String registrationId)
+
+
Called after a device has been unregistered. +

+

+
Parameters:
registrationId - the registration id that was previously registered.
context - application's context.
+
+
+
+ +

+onHandleIntent

+
+public final void onHandleIntent(Intent intent)
+
+
+
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + diff --git a/docs/html/guide/google/gcm/client-javadoc/com/google/android/gcm/GCMBroadcastReceiver.html b/docs/html/guide/google/gcm/client-javadoc/com/google/android/gcm/GCMBroadcastReceiver.html new file mode 100644 index 0000000000000..f0b3e26d05a59 --- /dev/null +++ b/docs/html/guide/google/gcm/client-javadoc/com/google/android/gcm/GCMBroadcastReceiver.html @@ -0,0 +1,282 @@ + + + + + + +GCMBroadcastReceiver + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +com.google.android.gcm +
+Class GCMBroadcastReceiver

+
+java.lang.Object
+  extended by BroadcastReceiver
+      extended by com.google.android.gcm.GCMBroadcastReceiver
+
+
+
+
public class GCMBroadcastReceiver
extends BroadcastReceiver
+ + +

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

+ By default, the GCMBaseIntentService class belongs to the application + main package and is named + GCMConstants.DEFAULT_INTENT_SERVICE_CLASS_NAME. To use a new class, + the getGCMIntentServiceClassName(Context) must be overridden. +

+ +

+


+ +

+ + + + + + + + + + + +
+Constructor Summary
GCMBroadcastReceiver() + +
+           
+  + + + + + + + + + + + + + + + +
+Method Summary
+protected  java.lang.StringgetGCMIntentServiceClassName(Context context) + +
+          Gets the class name of the intent service that will handle GCM messages.
+ voidonReceive(Context context, + Intent intent) + +
+           
+  + + + + + + + +
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
+  +

+ + + + + + + + +
+Constructor Detail
+ +

+GCMBroadcastReceiver

+
+public GCMBroadcastReceiver()
+
+
+ + + + + + + + +
+Method Detail
+ +

+onReceive

+
+public final void onReceive(Context context,
+                            Intent intent)
+
+
+
+
+
+
+ +

+getGCMIntentServiceClassName

+
+protected java.lang.String getGCMIntentServiceClassName(Context context)
+
+
Gets the class name of the intent service that will handle GCM messages. +

+

+
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + diff --git a/docs/html/guide/google/gcm/client-javadoc/com/google/android/gcm/GCMConstants.html b/docs/html/guide/google/gcm/client-javadoc/com/google/android/gcm/GCMConstants.html new file mode 100644 index 0000000000000..feb22256db9fb --- /dev/null +++ b/docs/html/guide/google/gcm/client-javadoc/com/google/android/gcm/GCMConstants.html @@ -0,0 +1,652 @@ + + + + + + +GCMConstants + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +com.google.android.gcm +
+Class GCMConstants

+
+java.lang.Object
+  extended by com.google.android.gcm.GCMConstants
+
+
+
+
public final class GCMConstants
extends java.lang.Object
+ + +

+Constants used by the GCM library. +

+ +

+


+ +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Field Summary
+static java.lang.StringDEFAULT_INTENT_SERVICE_CLASS_NAME + +
+           
+static java.lang.StringERROR_ACCOUNT_MISSING + +
+          There is no Google account on the phone.
+static java.lang.StringERROR_AUTHENTICATION_FAILED + +
+          Bad password.
+static java.lang.StringERROR_INVALID_PARAMETERS + +
+          The request sent by the phone does not contain the expected parameters.
+static java.lang.StringERROR_INVALID_SENDER + +
+          The sender account is not recognized.
+static java.lang.StringERROR_PHONE_REGISTRATION_ERROR + +
+          Incorrect phone registration with Google.
+static java.lang.StringERROR_SERVICE_NOT_AVAILABLE + +
+          The device can't read the response, or there was a 500/503 from the + server that can be retried later.
+static java.lang.StringEXTRA_APPLICATION_PENDING_INTENT + +
+          Extra used on INTENT_TO_GCM_REGISTRATION to get the application + id.
+static java.lang.StringEXTRA_ERROR + +
+          Extra used on INTENT_FROM_GCM_REGISTRATION_CALLBACK to indicate + an error when the registration fails.
+static java.lang.StringEXTRA_REGISTRATION_ID + +
+          Extra used on INTENT_FROM_GCM_REGISTRATION_CALLBACK to indicate + the registration id when the registration succeeds.
+static java.lang.StringEXTRA_SENDER + +
+          Extra used on INTENT_TO_GCM_REGISTRATION to indicate the sender + account (a Google email) that owns the application.
+static java.lang.StringEXTRA_SPECIAL_MESSAGE + +
+          Type of message present in the INTENT_FROM_GCM_MESSAGE intent.
+static java.lang.StringEXTRA_TOTAL_DELETED + +
+          Number of messages deleted by the server because the device was idle.
+static java.lang.StringEXTRA_UNREGISTERED + +
+          Extra used on INTENT_FROM_GCM_REGISTRATION_CALLBACK to indicate + that the application has been unregistered.
+static java.lang.StringINTENT_FROM_GCM_LIBRARY_RETRY + +
+          Intent used by the GCM library to indicate that the registration call + should be retried.
+static java.lang.StringINTENT_FROM_GCM_MESSAGE + +
+          Intent sent by GCM containing a message.
+static java.lang.StringINTENT_FROM_GCM_REGISTRATION_CALLBACK + +
+          Intent sent by GCM indicating with the result of a registration request.
+static java.lang.StringINTENT_TO_GCM_REGISTRATION + +
+          Intent sent to GCM to register the application.
+static java.lang.StringINTENT_TO_GCM_UNREGISTRATION + +
+          Intent sent to GCM to unregister the application.
+static java.lang.StringPERMISSION_GCM_INTENTS + +
+          Permission necessary to receive GCM intents.
+static java.lang.StringVALUE_DELETED_MESSAGES + +
+          Special message indicating the server deleted the pending messages.
+  + + + + + + + +
+Method Summary
+  + + + + + + + +
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
+  +

+ + + + + + + + +
+Field Detail
+ +

+INTENT_TO_GCM_REGISTRATION

+
+public static final java.lang.String INTENT_TO_GCM_REGISTRATION
+
+
Intent sent to GCM to register the application. +

+

+
See Also:
Constant Field Values
+
+
+ +

+INTENT_TO_GCM_UNREGISTRATION

+
+public static final java.lang.String INTENT_TO_GCM_UNREGISTRATION
+
+
Intent sent to GCM to unregister the application. +

+

+
See Also:
Constant Field Values
+
+
+ +

+INTENT_FROM_GCM_REGISTRATION_CALLBACK

+
+public static final java.lang.String INTENT_FROM_GCM_REGISTRATION_CALLBACK
+
+
Intent sent by GCM indicating with the result of a registration request. +

+

+
See Also:
Constant Field Values
+
+
+ +

+INTENT_FROM_GCM_LIBRARY_RETRY

+
+public static final java.lang.String INTENT_FROM_GCM_LIBRARY_RETRY
+
+
Intent used by the GCM library to indicate that the registration call + should be retried. +

+

+
See Also:
Constant Field Values
+
+
+ +

+INTENT_FROM_GCM_MESSAGE

+
+public static final java.lang.String INTENT_FROM_GCM_MESSAGE
+
+
Intent sent by GCM containing a message. +

+

+
See Also:
Constant Field Values
+
+
+ +

+EXTRA_SENDER

+
+public static final java.lang.String EXTRA_SENDER
+
+
Extra used on INTENT_TO_GCM_REGISTRATION to indicate the sender + account (a Google email) that owns the application. +

+

+
See Also:
Constant Field Values
+
+
+ +

+EXTRA_APPLICATION_PENDING_INTENT

+
+public static final java.lang.String EXTRA_APPLICATION_PENDING_INTENT
+
+
Extra used on INTENT_TO_GCM_REGISTRATION to get the application + id. +

+

+
See Also:
Constant Field Values
+
+
+ +

+EXTRA_UNREGISTERED

+
+public static final java.lang.String EXTRA_UNREGISTERED
+
+
Extra used on INTENT_FROM_GCM_REGISTRATION_CALLBACK to indicate + that the application has been unregistered. +

+

+
See Also:
Constant Field Values
+
+
+ +

+EXTRA_ERROR

+
+public static final java.lang.String EXTRA_ERROR
+
+
Extra used on INTENT_FROM_GCM_REGISTRATION_CALLBACK to indicate + an error when the registration fails. See constants starting with ERROR_ + for possible values. +

+

+
See Also:
Constant Field Values
+
+
+ +

+EXTRA_REGISTRATION_ID

+
+public static final java.lang.String EXTRA_REGISTRATION_ID
+
+
Extra used on INTENT_FROM_GCM_REGISTRATION_CALLBACK to indicate + the registration id when the registration succeeds. +

+

+
See Also:
Constant Field Values
+
+
+ +

+EXTRA_SPECIAL_MESSAGE

+
+public static final java.lang.String EXTRA_SPECIAL_MESSAGE
+
+
Type of message present in the INTENT_FROM_GCM_MESSAGE intent. + This extra is only set for special messages sent from GCM, not for + messages originated from the application. +

+

+
See Also:
Constant Field Values
+
+
+ +

+VALUE_DELETED_MESSAGES

+
+public static final java.lang.String VALUE_DELETED_MESSAGES
+
+
Special message indicating the server deleted the pending messages. +

+

+
See Also:
Constant Field Values
+
+
+ +

+EXTRA_TOTAL_DELETED

+
+public static final java.lang.String EXTRA_TOTAL_DELETED
+
+
Number of messages deleted by the server because the device was idle. + Present only on messages of special type + VALUE_DELETED_MESSAGES +

+

+
See Also:
Constant Field Values
+
+
+ +

+PERMISSION_GCM_INTENTS

+
+public static final java.lang.String PERMISSION_GCM_INTENTS
+
+
Permission necessary to receive GCM intents. +

+

+
See Also:
Constant Field Values
+
+
+ +

+DEFAULT_INTENT_SERVICE_CLASS_NAME

+
+public static final java.lang.String DEFAULT_INTENT_SERVICE_CLASS_NAME
+
+
+
See Also:
GCMBroadcastReceiver, +Constant Field Values
+
+
+ +

+ERROR_SERVICE_NOT_AVAILABLE

+
+public static final java.lang.String ERROR_SERVICE_NOT_AVAILABLE
+
+
The device can't read the response, or there was a 500/503 from the + server that can be retried later. The application should use exponential + back off and retry. +

+

+
See Also:
Constant Field Values
+
+
+ +

+ERROR_ACCOUNT_MISSING

+
+public static final java.lang.String ERROR_ACCOUNT_MISSING
+
+
There is no Google account on the phone. The application should ask the + user to open the account manager and add a Google account. +

+

+
See Also:
Constant Field Values
+
+
+ +

+ERROR_AUTHENTICATION_FAILED

+
+public static final java.lang.String ERROR_AUTHENTICATION_FAILED
+
+
Bad password. The application should ask the user to enter his/her + password, and let user retry manually later. Fix on the device side. +

+

+
See Also:
Constant Field Values
+
+
+ +

+ERROR_INVALID_PARAMETERS

+
+public static final java.lang.String ERROR_INVALID_PARAMETERS
+
+
The request sent by the phone does not contain the expected parameters. + This phone doesn't currently support GCM. +

+

+
See Also:
Constant Field Values
+
+
+ +

+ERROR_INVALID_SENDER

+
+public static final java.lang.String ERROR_INVALID_SENDER
+
+
The sender account is not recognized. Fix on the device side. +

+

+
See Also:
Constant Field Values
+
+
+ +

+ERROR_PHONE_REGISTRATION_ERROR

+
+public static final java.lang.String ERROR_PHONE_REGISTRATION_ERROR
+
+
Incorrect phone registration with Google. This phone doesn't currently + support GCM. +

+

+
See Also:
Constant Field Values
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + diff --git a/docs/html/guide/google/gcm/client-javadoc/com/google/android/gcm/GCMRegistrar.html b/docs/html/guide/google/gcm/client-javadoc/com/google/android/gcm/GCMRegistrar.html new file mode 100644 index 0000000000000..a933bc6f07a99 --- /dev/null +++ b/docs/html/guide/google/gcm/client-javadoc/com/google/android/gcm/GCMRegistrar.html @@ -0,0 +1,445 @@ + + + + + + +GCMRegistrar + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +com.google.android.gcm +
+Class GCMRegistrar

+
+java.lang.Object
+  extended by com.google.android.gcm.GCMRegistrar
+
+
+
+
public final class GCMRegistrar
extends java.lang.Object
+ + +

+Utilities for device registration. +

+ Note: this class uses a private SharedPreferences + object to keep track of the registration token. +

+ +

+


+ +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Method Summary
+static voidcheckDevice(Context context) + +
+          Checks if the device has the proper dependencies installed.
+static voidcheckManifest(Context context) + +
+          Checks that the application manifest is properly configured.
+static java.lang.StringgetRegistrationId(Context context) + +
+          Gets the current registration id for application on GCM service.
+static booleanisRegistered(Context context) + +
+          Checks whether the application was successfully registered on GCM + service.
+static booleanisRegisteredOnServer(Context context) + +
+          Checks whether the device was successfully registered in the server side.
+static voidonDestroy(Context context) + +
+          Clear internal resources.
+static voidregister(Context context, + java.lang.String... senderIds) + +
+          Initiate messaging registration for the current application.
+static voidsetRegisteredOnServer(Context context, + boolean flag) + +
+          Sets whether the device was successfully registered in the server side.
+static voidunregister(Context context) + +
+          Unregister the application.
+  + + + + + + + +
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
+  +

+ + + + + + + + +
+Method Detail
+ +

+checkDevice

+
+public static void checkDevice(Context context)
+
+
Checks if the device has the proper dependencies installed. +

+ This method should be called when the application starts to verify that + the device supports GCM. +

+

+
Parameters:
context - application context. +
Throws: +
java.lang.UnsupportedOperationException - if the device does not support GCM.
+
+
+
+ +

+checkManifest

+
+public static void checkManifest(Context context)
+
+
Checks that the application manifest is properly configured. +

+ A proper configuration means: +

    +
  1. It creates a custom permission called + PACKAGE_NAME.permission.C2D_MESSAGE. +
  2. It defines at least one BroadcastReceiver with category + PACKAGE_NAME. +
  3. The BroadcastReceiver(s) uses the + permission. +
  4. The BroadcastReceiver(s) handles the 3 GCM intents + (, + , + and ). +
+ ...where PACKAGE_NAME is the application package. +

+ This method should be used during development time to verify that the + manifest is properly set up, but it doesn't need to be called once the + application is deployed to the users' devices. +

+

+
Parameters:
context - application context. +
Throws: +
java.lang.IllegalStateException - if any of the conditions above is not met.
+
+
+
+ +

+register

+
+public static void register(Context context,
+                            java.lang.String... senderIds)
+
+
Initiate messaging registration for the current application. +

+ The result will be returned as an + GCMConstants.INTENT_FROM_GCM_REGISTRATION_CALLBACK intent with + either a GCMConstants.EXTRA_REGISTRATION_ID or + GCMConstants.EXTRA_ERROR. +

+

+
Parameters:
context - application context.
senderIds - Google Project ID of the accounts authorized to send + messages to this application. +
Throws: +
java.lang.IllegalStateException - if device does not have all GCM + dependencies installed.
+
+
+
+ +

+unregister

+
+public static void unregister(Context context)
+
+
Unregister the application. +

+ The result will be returned as an + GCMConstants.INTENT_FROM_GCM_REGISTRATION_CALLBACK intent with an + GCMConstants.EXTRA_UNREGISTERED extra. +

+

+
+
+
+
+ +

+onDestroy

+
+public static void onDestroy(Context context)
+
+
Clear internal resources. + +

+ This method should be called by the main activity's onDestroy() + method. +

+

+
+
+
+
+ +

+getRegistrationId

+
+public static java.lang.String getRegistrationId(Context context)
+
+
Gets the current registration id for application on GCM service. +

+ If result is empty, the registration has failed. +

+

+ +
Returns:
registration id, or empty string if the registration is not + complete.
+
+
+
+ +

+isRegistered

+
+public static boolean isRegistered(Context context)
+
+
Checks whether the application was successfully registered on GCM + service. +

+

+
+
+
+
+ +

+setRegisteredOnServer

+
+public static void setRegisteredOnServer(Context context,
+                                         boolean flag)
+
+
Sets whether the device was successfully registered in the server side. +

+

+
+
+
+
+ +

+isRegisteredOnServer

+
+public static boolean isRegisteredOnServer(Context context)
+
+
Checks whether the device was successfully registered in the server side. +

+

+
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + diff --git a/docs/html/guide/google/gcm/client-javadoc/com/google/android/gcm/package-frame.html b/docs/html/guide/google/gcm/client-javadoc/com/google/android/gcm/package-frame.html new file mode 100644 index 0000000000000..9dc665fa12297 --- /dev/null +++ b/docs/html/guide/google/gcm/client-javadoc/com/google/android/gcm/package-frame.html @@ -0,0 +1,38 @@ + + + + + + +com.google.android.gcm + + + + + + + + + + + +com.google.android.gcm + + + + +
+Classes  + +
+GCMBaseIntentService +
+GCMBroadcastReceiver +
+GCMConstants +
+GCMRegistrar
+ + + + diff --git a/docs/html/guide/google/gcm/client-javadoc/com/google/android/gcm/package-summary.html b/docs/html/guide/google/gcm/client-javadoc/com/google/android/gcm/package-summary.html new file mode 100644 index 0000000000000..2b15b813e1f10 --- /dev/null +++ b/docs/html/guide/google/gcm/client-javadoc/com/google/android/gcm/package-summary.html @@ -0,0 +1,167 @@ + + + + + + +com.google.android.gcm + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+

+Package com.google.android.gcm +

+ + + + + + + + + + + + + + + + + + + + + +
+Class Summary
GCMBaseIntentServiceSkeleton for application-specific IntentServices responsible for + handling communication from Google Cloud Messaging service.
GCMBroadcastReceiverBroadcastReceiver that receives GCM messages and delivers them to + an application-specific GCMBaseIntentService subclass.
GCMConstantsConstants used by the GCM library.
GCMRegistrarUtilities for device registration.
+  + +

+

+
+
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + diff --git a/docs/html/guide/google/gcm/client-javadoc/com/google/android/gcm/package-tree.html b/docs/html/guide/google/gcm/client-javadoc/com/google/android/gcm/package-tree.html new file mode 100644 index 0000000000000..f36a8a6986cbc --- /dev/null +++ b/docs/html/guide/google/gcm/client-javadoc/com/google/android/gcm/package-tree.html @@ -0,0 +1,150 @@ + + + + + + +com.google.android.gcm Class Hierarchy + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+
+

+Hierarchy For Package com.google.android.gcm +

+
+

+Class Hierarchy +

+ +
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + diff --git a/docs/html/guide/google/gcm/client-javadoc/constant-values.html b/docs/html/guide/google/gcm/client-javadoc/constant-values.html new file mode 100644 index 0000000000000..171c6a177bc6e --- /dev/null +++ b/docs/html/guide/google/gcm/client-javadoc/constant-values.html @@ -0,0 +1,308 @@ + + + + + + +Constant Field Values + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+
+

+Constant Field Values

+
+
+Contents + + + + + + +
+com.google.*
+ +

+ + + + + + + + + + + + +
com.google.android.gcm.GCMBaseIntentService
+public static final java.lang.StringTAG"GCMBaseIntentService"
+ +

+ +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
com.google.android.gcm.GCMConstants
+public static final java.lang.StringDEFAULT_INTENT_SERVICE_CLASS_NAME".GCMIntentService"
+public static final java.lang.StringERROR_ACCOUNT_MISSING"ACCOUNT_MISSING"
+public static final java.lang.StringERROR_AUTHENTICATION_FAILED"AUTHENTICATION_FAILED"
+public static final java.lang.StringERROR_INVALID_PARAMETERS"INVALID_PARAMETERS"
+public static final java.lang.StringERROR_INVALID_SENDER"INVALID_SENDER"
+public static final java.lang.StringERROR_PHONE_REGISTRATION_ERROR"PHONE_REGISTRATION_ERROR"
+public static final java.lang.StringERROR_SERVICE_NOT_AVAILABLE"SERVICE_NOT_AVAILABLE"
+public static final java.lang.StringEXTRA_APPLICATION_PENDING_INTENT"app"
+public static final java.lang.StringEXTRA_ERROR"error"
+public static final java.lang.StringEXTRA_REGISTRATION_ID"registration_id"
+public static final java.lang.StringEXTRA_SENDER"sender"
+public static final java.lang.StringEXTRA_SPECIAL_MESSAGE"message_type"
+public static final java.lang.StringEXTRA_TOTAL_DELETED"total_deleted"
+public static final java.lang.StringEXTRA_UNREGISTERED"unregistered"
+public static final java.lang.StringINTENT_FROM_GCM_LIBRARY_RETRY"com.google.android.gcm.intent.RETRY"
+public static final java.lang.StringINTENT_FROM_GCM_MESSAGE"com.google.android.c2dm.intent.RECEIVE"
+public static final java.lang.StringINTENT_FROM_GCM_REGISTRATION_CALLBACK"com.google.android.c2dm.intent.REGISTRATION"
+public static final java.lang.StringINTENT_TO_GCM_REGISTRATION"com.google.android.c2dm.intent.REGISTER"
+public static final java.lang.StringINTENT_TO_GCM_UNREGISTRATION"com.google.android.c2dm.intent.UNREGISTER"
+public static final java.lang.StringPERMISSION_GCM_INTENTS"com.google.android.c2dm.permission.SEND"
+public static final java.lang.StringVALUE_DELETED_MESSAGES"deleted_messages"
+ +

+ +

+


+ + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + diff --git a/docs/html/guide/google/gcm/client-javadoc/deprecated-list.html b/docs/html/guide/google/gcm/client-javadoc/deprecated-list.html new file mode 100644 index 0000000000000..ebdcc26a24487 --- /dev/null +++ b/docs/html/guide/google/gcm/client-javadoc/deprecated-list.html @@ -0,0 +1,142 @@ + + + + + + +Deprecated List + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+
+

+Deprecated API

+
+
+Contents + +
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + diff --git a/docs/html/guide/google/gcm/client-javadoc/help-doc.html b/docs/html/guide/google/gcm/client-javadoc/help-doc.html new file mode 100644 index 0000000000000..0dc47eb9829f3 --- /dev/null +++ b/docs/html/guide/google/gcm/client-javadoc/help-doc.html @@ -0,0 +1,209 @@ + + + + + + +API Help + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+
+

+How This API Document Is Organized

+
+This API (Application Programming Interface) document has pages corresponding to the items in the navigation bar, described as follows.

+Package

+
+ +

+Each package has a page that contains a list of its classes and interfaces, with a summary for each. This page can contain four categories:

+
+

+Class/Interface

+
+ +

+Each class, interface, nested class and nested interface has its own separate page. Each of these pages has three sections consisting of a class/interface description, summary tables, and detailed member descriptions:

+Each summary entry contains the first sentence from the detailed description for that item. The summary entries are alphabetical, while the detailed descriptions are in the order they appear in the source code. This preserves the logical groupings established by the programmer.
+ +

+Annotation Type

+
+ +

+Each annotation type has its own separate page with the following sections:

+
+ +

+Enum

+
+ +

+Each enum has its own separate page with the following sections:

+
+

+Tree (Class Hierarchy)

+
+There is a Class Hierarchy page for all packages, plus a hierarchy for each package. Each hierarchy page contains a list of classes and a list of interfaces. The classes are organized by inheritance structure starting with java.lang.Object. The interfaces do not inherit from java.lang.Object. +
+

+Deprecated API

+
+The Deprecated API page lists all of the API that have been deprecated. A deprecated API is not recommended for use, generally due to improvements, and a replacement API is usually given. Deprecated APIs may be removed in future implementations.
+

+Index

+
+The Index contains an alphabetic list of all classes, interfaces, constructors, methods, and fields.
+

+Prev/Next

+These links take you to the next or previous class, interface, package, or related page.

+Frames/No Frames

+These links show and hide the HTML frames. All pages are available with or without frames. +

+

+Serialized Form

+Each serializable or externalizable class has a description of its serialization fields and methods. This information is of interest to re-implementors, not to developers using the API. While there is no link in the navigation bar, you can get to this information by going to any serialized class and clicking "Serialized Form" in the "See also" section of the class description. +

+

+Constant Field Values

+The Constant Field Values page lists the static final fields and their values. +

+ + +This help file applies to API documentation generated using the standard doclet. + +
+


+ + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + diff --git a/docs/html/guide/google/gcm/client-javadoc/index-all.html b/docs/html/guide/google/gcm/client-javadoc/index-all.html new file mode 100644 index 0000000000000..43b8e4ecf5718 --- /dev/null +++ b/docs/html/guide/google/gcm/client-javadoc/index-all.html @@ -0,0 +1,331 @@ + + + + + + +Index + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + +
+ +
+ + + +C D E G I O P R S T U V
+

+C

+
+
checkDevice(Context) - +Static method in class com.google.android.gcm.GCMRegistrar +
Checks if the device has the proper dependencies installed. +
checkManifest(Context) - +Static method in class com.google.android.gcm.GCMRegistrar +
Checks that the application manifest is properly configured. +
com.google.android.gcm - package com.google.android.gcm
 
+
+

+D

+
+
DEFAULT_INTENT_SERVICE_CLASS_NAME - +Static variable in class com.google.android.gcm.GCMConstants +
  +
+
+

+E

+
+
ERROR_ACCOUNT_MISSING - +Static variable in class com.google.android.gcm.GCMConstants +
There is no Google account on the phone. +
ERROR_AUTHENTICATION_FAILED - +Static variable in class com.google.android.gcm.GCMConstants +
Bad password. +
ERROR_INVALID_PARAMETERS - +Static variable in class com.google.android.gcm.GCMConstants +
The request sent by the phone does not contain the expected parameters. +
ERROR_INVALID_SENDER - +Static variable in class com.google.android.gcm.GCMConstants +
The sender account is not recognized. +
ERROR_PHONE_REGISTRATION_ERROR - +Static variable in class com.google.android.gcm.GCMConstants +
Incorrect phone registration with Google. +
ERROR_SERVICE_NOT_AVAILABLE - +Static variable in class com.google.android.gcm.GCMConstants +
The device can't read the response, or there was a 500/503 from the + server that can be retried later. +
EXTRA_APPLICATION_PENDING_INTENT - +Static variable in class com.google.android.gcm.GCMConstants +
Extra used on GCMConstants.INTENT_TO_GCM_REGISTRATION to get the application + id. +
EXTRA_ERROR - +Static variable in class com.google.android.gcm.GCMConstants +
Extra used on GCMConstants.INTENT_FROM_GCM_REGISTRATION_CALLBACK to indicate + an error when the registration fails. +
EXTRA_REGISTRATION_ID - +Static variable in class com.google.android.gcm.GCMConstants +
Extra used on GCMConstants.INTENT_FROM_GCM_REGISTRATION_CALLBACK to indicate + the registration id when the registration succeeds. +
EXTRA_SENDER - +Static variable in class com.google.android.gcm.GCMConstants +
Extra used on GCMConstants.INTENT_TO_GCM_REGISTRATION to indicate the sender + account (a Google email) that owns the application. +
EXTRA_SPECIAL_MESSAGE - +Static variable in class com.google.android.gcm.GCMConstants +
Type of message present in the GCMConstants.INTENT_FROM_GCM_MESSAGE intent. +
EXTRA_TOTAL_DELETED - +Static variable in class com.google.android.gcm.GCMConstants +
Number of messages deleted by the server because the device was idle. +
EXTRA_UNREGISTERED - +Static variable in class com.google.android.gcm.GCMConstants +
Extra used on GCMConstants.INTENT_FROM_GCM_REGISTRATION_CALLBACK to indicate + that the application has been unregistered. +
+
+

+G

+
+
GCMBaseIntentService - Class in com.google.android.gcm
Skeleton for application-specific IntentServices responsible for + handling communication from Google Cloud Messaging service.
GCMBaseIntentService(String) - +Constructor for class com.google.android.gcm.GCMBaseIntentService +
Subclasses must create a public no-arg constructor and pass the + sender id to be used for registration. +
GCMBroadcastReceiver - Class in com.google.android.gcm
BroadcastReceiver that receives GCM messages and delivers them to + an application-specific GCMBaseIntentService subclass.
GCMBroadcastReceiver() - +Constructor for class com.google.android.gcm.GCMBroadcastReceiver +
  +
GCMConstants - Class in com.google.android.gcm
Constants used by the GCM library.
GCMRegistrar - Class in com.google.android.gcm
Utilities for device registration.
getGCMIntentServiceClassName(Context) - +Method in class com.google.android.gcm.GCMBroadcastReceiver +
Gets the class name of the intent service that will handle GCM messages. +
getRegistrationId(Context) - +Static method in class com.google.android.gcm.GCMRegistrar +
Gets the current registration id for application on GCM service. +
+
+

+I

+
+
INTENT_FROM_GCM_LIBRARY_RETRY - +Static variable in class com.google.android.gcm.GCMConstants +
Intent used by the GCM library to indicate that the registration call + should be retried. +
INTENT_FROM_GCM_MESSAGE - +Static variable in class com.google.android.gcm.GCMConstants +
Intent sent by GCM containing a message. +
INTENT_FROM_GCM_REGISTRATION_CALLBACK - +Static variable in class com.google.android.gcm.GCMConstants +
Intent sent by GCM indicating with the result of a registration request. +
INTENT_TO_GCM_REGISTRATION - +Static variable in class com.google.android.gcm.GCMConstants +
Intent sent to GCM to register the application. +
INTENT_TO_GCM_UNREGISTRATION - +Static variable in class com.google.android.gcm.GCMConstants +
Intent sent to GCM to unregister the application. +
isRegistered(Context) - +Static method in class com.google.android.gcm.GCMRegistrar +
Checks whether the application was successfully registered on GCM + service. +
isRegisteredOnServer(Context) - +Static method in class com.google.android.gcm.GCMRegistrar +
Checks whether the device was successfully registered in the server side. +
+
+

+O

+
+
onDeletedMessages(Context, int) - +Method in class com.google.android.gcm.GCMBaseIntentService +
Called when the GCM server tells pending messages have been deleted + because the device was idle. +
onDestroy(Context) - +Static method in class com.google.android.gcm.GCMRegistrar +
Clear internal resources. +
onError(Context, String) - +Method in class com.google.android.gcm.GCMBaseIntentService +
Called on registration or unregistration error. +
onHandleIntent(Intent) - +Method in class com.google.android.gcm.GCMBaseIntentService +
  +
onMessage(Context, Intent) - +Method in class com.google.android.gcm.GCMBaseIntentService +
Called when a cloud message has been received. +
onReceive(Context, Intent) - +Method in class com.google.android.gcm.GCMBroadcastReceiver +
  +
onRecoverableError(Context, String) - +Method in class com.google.android.gcm.GCMBaseIntentService +
Called on a registration error that could be retried. +
onRegistered(Context, String) - +Method in class com.google.android.gcm.GCMBaseIntentService +
Called after a device has been registered. +
onUnregistered(Context, String) - +Method in class com.google.android.gcm.GCMBaseIntentService +
Called after a device has been unregistered. +
+
+

+P

+
+
PERMISSION_GCM_INTENTS - +Static variable in class com.google.android.gcm.GCMConstants +
Permission necessary to receive GCM intents. +
+
+

+R

+
+
register(Context, String...) - +Static method in class com.google.android.gcm.GCMRegistrar +
Initiate messaging registration for the current application. +
+
+

+S

+
+
setRegisteredOnServer(Context, boolean) - +Static method in class com.google.android.gcm.GCMRegistrar +
Sets whether the device was successfully registered in the server side. +
+
+

+T

+
+
TAG - +Static variable in class com.google.android.gcm.GCMBaseIntentService +
  +
+
+

+U

+
+
unregister(Context) - +Static method in class com.google.android.gcm.GCMRegistrar +
Unregister the application. +
+
+

+V

+
+
VALUE_DELETED_MESSAGES - +Static variable in class com.google.android.gcm.GCMConstants +
Special message indicating the server deleted the pending messages. +
+
+C D E G I O P R S T U V + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + diff --git a/docs/html/guide/google/gcm/client-javadoc/index.html b/docs/html/guide/google/gcm/client-javadoc/index.html new file mode 100644 index 0000000000000..a7753f74246d1 --- /dev/null +++ b/docs/html/guide/google/gcm/client-javadoc/index.html @@ -0,0 +1,38 @@ + + + + + + +Generated Documentation (Untitled) + + + + + + + + + + +<H2> +Frame Alert</H2> + +<P> +This document is designed to be viewed using the frames feature. If you see this message, you are using a non-frame-capable web client. +<BR> +Link to<A HREF="com/google/android/gcm/package-summary.html">Non-frame version.</A> + + + diff --git a/docs/html/guide/google/gcm/client-javadoc/overview-tree.html b/docs/html/guide/google/gcm/client-javadoc/overview-tree.html new file mode 100644 index 0000000000000..6ea6fb3eea171 --- /dev/null +++ b/docs/html/guide/google/gcm/client-javadoc/overview-tree.html @@ -0,0 +1,152 @@ + + + + + + +Class Hierarchy + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+
+

+Hierarchy For All Packages

+
+
+
Package Hierarchies:
com.google.android.gcm
+
+

+Class Hierarchy +

+ +
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + diff --git a/docs/html/guide/google/gcm/client-javadoc/package-list b/docs/html/guide/google/gcm/client-javadoc/package-list new file mode 100644 index 0000000000000..149691e0828da --- /dev/null +++ b/docs/html/guide/google/gcm/client-javadoc/package-list @@ -0,0 +1 @@ +com.google.android.gcm diff --git a/docs/html/guide/google/gcm/client-javadoc/resources/inherit.gif b/docs/html/guide/google/gcm/client-javadoc/resources/inherit.gif new file mode 100644 index 0000000000000..c814867a13deb Binary files /dev/null and b/docs/html/guide/google/gcm/client-javadoc/resources/inherit.gif differ diff --git a/docs/html/guide/google/gcm/client-javadoc/stylesheet.css b/docs/html/guide/google/gcm/client-javadoc/stylesheet.css new file mode 100644 index 0000000000000..6ea9e5161615f --- /dev/null +++ b/docs/html/guide/google/gcm/client-javadoc/stylesheet.css @@ -0,0 +1,29 @@ +/* Javadoc style sheet */ + +/* Define colors, fonts and other style attributes here to override the defaults */ + +/* Page background color */ +body { background-color: #FFFFFF; color:#000000 } + +/* Headings */ +h1 { font-size: 145% } + +/* Table colors */ +.TableHeadingColor { background: #CCCCFF; color:#000000 } /* Dark mauve */ +.TableSubHeadingColor { background: #EEEEFF; color:#000000 } /* Light mauve */ +.TableRowColor { background: #FFFFFF; color:#000000 } /* White */ + +/* Font used in left-hand frame lists */ +.FrameTitleFont { font-size: 100%; font-family: Helvetica, Arial, sans-serif; color:#000000 } +.FrameHeadingFont { font-size: 90%; font-family: Helvetica, Arial, sans-serif; color:#000000 } +.FrameItemFont { font-size: 90%; font-family: Helvetica, Arial, sans-serif; color:#000000 } + +/* Navigation bar fonts and colors */ +.NavBarCell1 { background-color:#EEEEFF; color:#000000} /* Light mauve */ +.NavBarCell1Rev { background-color:#00008B; color:#FFFFFF} /* Dark Blue */ +.NavBarFont1 { font-family: Arial, Helvetica, sans-serif; color:#000000;color:#000000;} +.NavBarFont1Rev { font-family: Arial, Helvetica, sans-serif; color:#FFFFFF;color:#FFFFFF;} + +.NavBarCell2 { font-family: Arial, Helvetica, sans-serif; background-color:#FFFFFF; color:#000000} +.NavBarCell3 { font-family: Arial, Helvetica, sans-serif; background-color:#FFFFFF; color:#000000} + diff --git a/docs/html/guide/google/gcm/demo.jd b/docs/html/guide/google/gcm/demo.jd new file mode 100644 index 0000000000000..2e1e9755180d6 --- /dev/null +++ b/docs/html/guide/google/gcm/demo.jd @@ -0,0 +1,259 @@ +page.title=GCM Demo Application +@jd:body + +
+
+ +

Quickview

+ + + + +

In this document

+ +
    +
  1. Requirements
  2. +
  3. Setting Up GCM
  4. +
  5. Setting Up the Server +
      +
    1. Using a standard web server
    2. +
    3. Using App Engine for Java
    4. +
    +
  6. +
  7. Setting Up the Device
  8. +
+ +
+
+ +

The Google Cloud Messaging (GCM) Demo demonstrates how to use the Google Cloud Messaging framework in your Android application. This tutorial walks you through setting up and running the demo.

+ + +

This demo consists of the following pieces:

+ +

Here is the API reference documentation for the helper libraries on which the demo is based:

+ +

Requirements

+

For the web server:

+ +

For the Android application:

+ +

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 the Server

+

This section describes the different options for setting up a server.

+

Using a standard web server

+

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

+
    +
  1. From the SDK Manager, install Extras > Google Cloud Messaging for Android Library. + + +

    This creates a gcm directory under YOUR_SDK_ROOT/extras/google/ containing these subdirectories: gcm-client, gcm-demo-appengine, gcm-demo-client, gcm-demo-server, and gcm-server.

    +
  2. + +
  3. In a text editor, edit the gcm-demo-server/WebContent/WEB-INF/classes/api.key and replace the existing text with the API key obtained above.
  4. +
  5. In a shell window, go to the gcm-demo-server directory.
  6. +
  7. Generate the server's WAR file by running ant war:
  8. + +
    $ 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
    +
    + +
  9. 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.
  10. +
  11. 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. + +
  12. +
+

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. From the SDK Manager, install Extras > Google Cloud Messaging for Android Library. +

    This creates a gcm directory under YOUR_SDK_ROOT/extras/google/ containing these subdirectories: gcm-client, gcm-demo-appengine, gcm-demo-client, gcm-demo-server, and gcm-server.

    +
  2. +
  3. In a text editor, edit the 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 gcm-api-server 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.

+

Setting Up the Device

+

To set up the device:

+
    +
  1. From the SDK Manager, install Extras > Google Cloud Messaging for Android Library. +

    This creates a gcm directory under YOUR_SDK_ROOT/extras/google containing these subdirectories: gcm-client, gcm-demo-appengine, gcm-demo-client, gcm-demo-server, gcm-server, and source.properties.

    +
  2. +
  3. Using a text editor, open gcm-demo-client/src/com/google/android/gcm/demo/app/CommonUtilities.java and set the proper values for the SENDER_ID and SERVER_URL constants. For example:
  4. + +
    +static final String SERVER_URL = "http://192.168.1.10:8080/gcm-demo";
    +static final String SENDER_ID = "4815162342";
    +

    Note that the SERVER_URL is the URL for the server and the application's context (or just server, if you are using App Engine), and it does not include the forward slash (/). Also note that SENDER_ID is the Google API project ID you obtained in the server setup steps above.

    + +
  5. In a shell window, go to the gcm-demo-client directory.
  6. +
  7. Use the SDK's android tool to generate the ant build files:
  8. + +
    +$ android update project --name GCMDemo -p . --target android-16
    +Updated project.properties
    +Updated local.properties
    +Updated file ./build.xml
    +Updated file ./proguard-project.txt
    +
    +

    If this command fails becase android-16 is not recognized, try a different target (as long as it is at least android-15).

    + +
  9. Use ant to build the application's APK file:
  10. + +
    +$ ant clean debug
    +Buildfile: build.xml
    +
    +...
    +
    +
    +-do-debug:
    +[zipalign] Running zip align on final apk...
    +    [echo] Debug Package: bin/GCMDemo-debug.apk
    +[propertyfile] Creating new property file: bin/build.prop
    +[propertyfile] Updating property file: bin/build.prop
    +[propertyfile] Updating property file: bin/build.prop
    +[propertyfile] Updating property file: bin/build.prop
    +
    +-post-build:
    +
    +debug:
    +
    +BUILD SUCCESSFUL
    +Total time: 3 seconds
    + 
    + +
  11. Start the Android emulator:
  12. +
    $emulator -avd my_avd
    +
    + +

    This example assumes there is an AVD (Android Virtual Device) named my_avd previously configured with Android 2.2 and Google APIs level 8. For more information on how to run an Android emulator, see Managing Virtual Devices in the Android Developers Guide.

    + +
  13. Make sure there is a Google account added to the emulator. It doesn't have to be any account (like the senderId) in particular.
  14. + +

    If the emulator is running Android 4.0.4 or later, this step is optional as GCM does not require an account from this version on.

    + +
  15. Install the application in the emulator:
  16. + +
    +$ ant installd
    +Buildfile: gcm-demo-client/build.xml
    +
    +-set-mode-check:
    +
    +-set-debug-files:
    +
    +install:
    +     [echo] Installing gcm-demo-client/bin/GCMDemo-debug.apk onto default emulator or device...
    +     [exec] 1719 KB/s (47158 bytes in 0.026s)
    +     [exec]   pkg: /data/local/tmp/GCMDemo-debug.apk
    +     [exec] Success
    +
    +installd:
    +
    +BUILD SUCCESSFUL
    +Total time: 3 seconds
    +
    +
  17. In the emulator, launch the GCM Demo app. The initial screen should look like this:
  18. +

    +

    Note: What happened? When the device received a registration callback intent from GCM, it contacted the server to register itself, using the register servlet and passing the registration ID received from GCM; the server then saved the registration ID to use it to send messages to the phone.

    +
  19. Now go back to your browser and refresh the page. It will show that there is one device registered:
  20. + +

    + +
  21. Click on Send Message. The browser should show:
  22. +

    + +

    And in your emulator:

    + +

    + +

    Note: What happened? When you clicked the button, the web server sent a message to GCM addressed to your device (more specifically, to the registration ID returned by GCM during the registration step). The device then received the message and displayed in the main activity; it also issued a system notification so the user would be notified even if the demo application was not running.

    +
+ diff --git a/docs/html/guide/google/gcm/gcm.jd b/docs/html/guide/google/gcm/gcm.jd new file mode 100644 index 0000000000000..d871fb4a94029 --- /dev/null +++ b/docs/html/guide/google/gcm/gcm.jd @@ -0,0 +1,943 @@ +page.title=GCM Architectural Overview +@jd:body + +
+
+ +

Quickview

+ + + + +

In this document

+ +
    +
  1. Introduction
  2. +
  3. Architectural Overview +
      +
    1. Lifecycle Flow
    2. +
    3. What Does the User See?
    4. +
    +
  4. +
  5. Writing Android Applications that use GCM +
      +
    1. Creating the Manifest
    2. +
    3. Registering for GCM
    4. +
    5. Unregistering from GCM
    6. +
    7. Handling Intents sent by GCM +
        +
      1. Handling Registration Results
      2. +
      3. Handling Received Data
      4. +
      +
    8. +
    9. Developing and Testing Your Android Applications
    10. +
    +
  6. +
  7. Role of the 3rd-party Application Server +
      +
    1. Sending Messages +
        +
      1. Request format
      2. +
      3. Response format
      4. +
      +
    2. +
    +
  8. Viewing statistics +
  9. +
  10. Examples
  11. +
+ + + +
+
+ +

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.

+

To jump right into using GCM with your Android + applications, see the instructions in Getting Started.

+ + + + +

Introduction

+ +

Here are the primary characteristics of Google Cloud +Messaging (GCM):

+ + +

Architectural Overview

+

This section gives an overview of how GCM works.

+

This table summarizes the key terms and concepts involved in GCM. It is +divided into these categories:

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Components
Mobile DeviceThe device that is running an Android application that uses +GCM. This must be a 2.2 Android device that has Google Play Store installed, and it must +have at least one logged in Google account if the device is running a version lower than Android 4.0.4. Alternatively, for testing you can use an emulator running Android 2.2 with Google APIs.
3rd-party Application ServerAn application server that developers set up as part of implementing +GCM in their applications. The 3rd-party application server sends data to an +Android application on the device via the GCM server.
GCM ServersThe Google servers involved in taking messages from the 3rd-party +application server and sending them to the device.
Credentials
Sender IDA project ID you acquire from the API console, as described in Getting Started. The sender +ID is used in the registration process to identify an +Android application that is permitted to send messages to the device.
Application IDThe Android application that is registering to receive messages. The Android application +is identified by the package name from the manifest. +This ensures that the messages are targeted to the correct Android application.
Registration IDAn ID issued by the GCM servers to the Android application that allows +it to receive messages. Once the Android application has the registration ID, it sends +it to the 3rd-party application server, which uses it to identify each device +that has registered to receive messages for a given Android application. In other words, +a registration ID is tied to a particular Android application running on a particular +device.
Google User AccountFor GCM to work, the mobile device must include at least one Google account if the device is running a version lower than Android 4.0.4.
Sender Auth TokenAn API key that is saved on the 3rd-party application +server that gives the application server authorized access to Google services. +The API key is included in the header of POST requests that send messages.
+ +

Lifecycle Flow

+ +

Here are the primary processes involved in cloud-to-device messaging:

+ + + +

These processes are described in more detail below.

+ +

Enabling GCM

+ +

This is the sequence of events that occurs when an Android application +running on a mobile device registers to receive messages:

+ +
    +
  1. The first time the Android application needs to use the messaging service, it +fires off a registration Intent to a GCM server. +

    This registration Intent +(com.google.android.c2dm.intent.REGISTER) includes the sender ID, and the Android application ID.

    +

    Note: Because there is no lifecycle method that is called when the application is run for +the first time, the registration intent should be sent on onCreate(), but only if the application is not registered yet. +

    +
  2. +
  3. If the registration is successful, the GCM server broadcasts a com.google.android.c2dm.intent.REGISTRATION intent which gives the Android application a registration +ID. +

    The Android application should store this ID for later use (for instance, to check on onCreate() if it is already registered). +Note that Google may periodically refresh the registration ID, so you should design your Android application +with the understanding that the com.google.android.c2dm.intent.REGISTRATION intent may be called +multiple times. Your Android application needs to be able to respond +accordingly.

  4. +
  5. To complete the registration, the Android application sends the registration ID to +the application server. The application server typically stores the registration +ID in a database.
  6. +
+ +

The registration ID lasts until the Android application explicitly unregisters +itself, or until Google refreshes the registration ID for your Android application.

+ +

Note: When users uninstall an application, it is not automatically unregistered on GCM. It is only unregistered when the GCM server tries to send a message to the device and the device answers that the application is uninstalled. At that point, you server should mark the device as unregistered (the server will receive a NotRegistered error). +

+Note that it might take a few minutes for the registration ID to be completed removed from the GCM server. So if the 3rd party server sends a message during this time, it will get a valid message ID, even though the message will not be delivered to the device.

+

+ +

Sending a Message

+ +

For an application server to send a message to an Android application, the following things must be in +place:

+ + + +

Here is the sequence of events that occurs when the application server sends a +message:

+ +
    +
  1. The application server sends a message to GCM servers.
  2. +
  3. Google enqueues and stores the message in case the device is +offline.
  4. +
  5. When the device is online, Google sends the message to the device.
  6. +
  7. On the device, the system broadcasts the message to the specified +Android application via Intent broadcast with proper permissions, so that only the +targeted Android application gets the message. This wakes the Android application up. The +Android application does not need to be running beforehand to receive the message.
  8. +
  9. The Android application processes the message. If the Android application is doing +non-trivial processing, you may want to grab a {@link android.os.PowerManager.WakeLock} and do any processing in a Service.
  10. +
+ +

An Android application can unregister GCM if it no longer wants to receive +messages.

+ +

Receiving a Message

+ +

This is the sequence of events that occurs when an Android application +installed on a mobile device receives a message:

+ +
    +
  1. The system receives the incoming message and extracts the raw key/value +pairs from the message payload, if any.
  2. +
  3. The system passes the key/value pairs to the targeted Android application +in a com.google.android.c2dm.intent.RECEIVE Intent as a set of +extras.
  4. +
  5. The Android application extracts the raw data +from the com.google.android.c2dm.intent.RECEIVE Intent by key and processes the data.
  6. +
+ +

What Does the User See?

+ +

When mobile device users install Android applications that include GCM, the Google Play Store will inform them that the Android application +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 the Manifest

+ +

Every Android application must have an AndroidManifest.xml file (with +precisely that name) in its root directory. The manifest presents essential +information about the Android application to the Android system, information the +system must have before it can run any of the Android application's code (for more +discussion of the manifest file, see the Android Developers Guide. To use the GCM feature, the +manifest must include the following:

+ + + +

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: +

+ + + +

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. + +

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:

+ + + +

Role of the 3rd-party Application Server

+ +

Before you can write client Android applications that use the GCM feature, you must +have an application server that meets the following criteria:

+ + + +

Sending Messages

+

This section describes how the 3rd-party application server sends messages to one or more mobile devices. Note the following:

+ +

Before the 3rd-party application server can send a message to an + Android application, it must have received a registration ID from it.

+

Request format

+

To send a message, the application server issues a POST request to https://android.googleapis.com/gcm/send.

+

A message request is made of 2 parts: HTTP header and HTTP body.

+ +

The HTTP header must contain the following headers:

+ + +

For example: +

+
Content-Type:application/json
+Authorization:key=AIzaSyB-1uEai2WiUapxCs2Q0GZYzPu7Udno5aA
+
+{
+  "registration_id" : "APA91bHun4MxP5egoKMwt2KZFBaFUH-1RYqx...",
+  "data" : {
+    ...
+  },
+}
+

+

Note: If Content-Type is omitted, the format is assumed to be plain text.

+

+ +

The HTTP body content depends on whether you're using JSON or plain text. For JSON, it must contain a string representing a JSON object with the following fields:

+ + + + + + + + + + + + + + + + + + + + + + + + + +
FieldDescription
registration_idsA string array with the list of devices (registration IDs) receiving the message. It must contain at least 1 and at most 1000 registration IDs. To send a multicast message, you must use JSON. For sending a single message to a single device, you could use a JSON object with just 1 registration id, or plain text (see below). Required.
collapse_keyAn arbitrary string (such as "Updates Available") that is used to collapse a group of like messages +when the device is offline, so that only the last message gets sent to the +client. This is intended to avoid sending too many messages to the phone when it +comes back online. Note that since there is no guarantee of the order in which +messages get sent, the "last" message may not actually be the last +message sent by the application server. See Advanced Topics for more discussion of this topic. Optional, unless you are using the time_to_live parameter—in that case, you must also specify a collapse_key.
dataA 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. Optional.
delay_while_idleIf included, indicates that the message should not be sent immediately +if the device is idle. The server will wait for the device to become active, and +then only the last message for each collapse_key value will be +sent. Optional. The default value is false, and must be a JSON boolean.
time_to_liveHow long (in seconds) the message should be kept on GCM storage if the device is offline. Optional (default time-to-live is 4 weeks, and must be set as a JSON number). If you use this parameter, you must also specify a collapse_key.
+ +

If you are using plain text instead of JSON, the message fields must be set as HTTP parameters sent in the body, and their syntax is slightly different, as described below: + + + + + + + + + + + + + + + + + + + + + + + + + +
FieldDescription
registration_idMust contain the registration ID of the single device receiving the message. Required.
collapse_keySame as JSON (see previous table). Optional.
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.
delay_while_idleShould be represented as 1 or true for true, anything else for false. Optional. The default value is false.
time_to_liveSame as JSON (see previous table). Optional.
+ + + +

Example requests

+

Here is the smallest possible request (a message without any parameters and just one recipient) using JSON:

+
{ "registration_ids": [ "42" ] }
+ +

And here the same example using plain text:

+
registration_id=42
+ +

Here is a message with a payload and 6 recipients:

+
{ "data": {
+    "score": "5x1",
+    "time": "15:10"
+  },
+  "registration_ids": ["4", "8", "15", "16", "23", "42"]
+}
+

Here is a message with all optional fields set and 6 recipients:

+
{ "collapse_key": "score_update",
+  "time_to_live": 108,
+  "delay_while_idle": true,
+  "data": {
+    "score": "4x8",
+    "time": "15:16.2342"
+  },
+  "registration_ids":["4", "8", "15", "16", "23", "42"]
+}
+

And here is the same message using plain-text format (but just 1 recipient):

+ +
collapse_key=score_update&time_to_live=108&delay_while_idle=1&data.score=4x8&data.time=15:16.2342&registration_id=42
+  
+ +

Note: If your organization has a firewall that restricts the traffic to or from the Internet, you'll need to configure it to allow connectivity with GCM. The ports to open are: 5228, 5229, and 5230. GCM typically only uses 5228, but it sometimes uses 5229 and 5230. +GCM doesn't provide specific IPs. It changes IPs frequently. We recommend against using ACLs but if you must use them, take a broad approach such as the method suggested in this support link. +

+ +

Response format

+ +

There are two possible outcomes when trying to send a message:

+ + +

When the messge is processed successfully, the HTTP response has a 200 status and the body contains more information about the status of the message (including possible errors). When the request is rejected, +the HTTP response contains a non-200 status code (such as 400, 401, or 503).

+ +

The following table summarizes the statuses that the HTTP response header might contain. Click the troubleshoot link for advice on how to deal with each type of error.

+ + + + + + + + + + + + + + + + + + + + + + + + + +
ResponseDescription
200Message was processed successfully. The response body will contain more details about the message status, but its format will depend whether the request was JSON or plain text. See Interpreting a success response for more details.
400Only applies for JSON requests. Indicates that the request could not be parsed as JSON, or it contained invalid fields (for instance, passing a string where a number was expected). The exact failure reason is described in the response and the problem should be addressed before the request can be retried.
401There was an error authenticating the sender account. Troubleshoot
500There was an internal error in the GCM server while trying to process the request. Troubleshoot
503Indicates that the server is temporarily unavailable (i.e., because of timeouts, etc ). Sender must retry later, honoring any Retry-After header + included in the response. Application servers must implement exponential back-off. The GCM server took too long to process the request. Troubleshoot
+ +

Interpreting a success response

+

When a JSON request is successful (HTTP status code 200), the response body contains a JSON object with the following fields:

+ + + + + + + + + + + + + + + + + + + + + + + + + +
FieldDescription
multicast_idUnique ID (number) identifying the multicast message.
successNumber of messages that were processed without an error.
failureNumber of messages that could not be processed.
canonical_idsNumber of results that contain a canonical registration ID. See Advanced Topics for more discussion of this topic.
resultsArray of objects representing the status of the messages processed. The objects are listed in the same order as the request (i.e., for each registration ID in the request, its result is listed in the same index in the response) and they can have these fields:
+
    +
  • message_id: String representing the message when it was successfully processed.
  • +
  • registration_id: If set, means that GCM processed the message but it has another canonical registration ID for that device, so sender should replace the IDs on future requests (otherwise they might be rejected). This field is never set if there is an error in the request.
    +
  • +
  • error: String describing an error that occurred while processing the message for that recipient. The possible values are the same as documented in the above table, plus "Unavailable" (meaning GCM servers were busy and could not process the message for that particular recipient, so it could be retried).
  • +
+

If the value of failure and canonical_ids is 0, it's not necessary to parse the remainder of the response. Otherwise, we recommend that you iterate through the results field and do the following for each object in that list:

+ + +

When a plain-text request is successful (HTTP status code 200), the response body contains 1 or 2 lines in the form of key/value pairs. +The first line is always available and its content is either id=ID of sent message or Error=GCM error code. The second line, if available, +has the format of registration_id=canonical ID. The second line is optional, and it can only be sent if the first line is not an error. We recommend handling the plain-text response in a similar way as handling the JSON response:

+ + +

Interpreting an error response

+

Here are the recommendations for handling the different types of error that might occur when trying to send a message to a device:

+ +
+
Missing Registration ID
+
Check that the request contains a registration ID (either in the registration_id parameter in a plain text message, or in the registration_ids field in JSON). +
Happens when error code is MissingRegistration.
+
Invalid Registration ID
+
Check the formatting of the registration ID that you pass to the server. Make sure it matches the registration ID the phone receives in the com.google.android.c2dm.intent.REGISTRATION intent and that you're not truncating it or adding additional characters. +
Happens when error code is InvalidRegistration.
+
Mismatched Sender
+
A registration ID is tied to a certain group of senders. When an application registers for GCM usage, it must specify which senders are allowed to send messages. Make sure you're using one of those when trying to send messages to the device. If you switch to a different sender, the existing registration IDs won't work. +Happens when error code is MismatchSenderId.
+
Unregistered Device
+
An existing registration ID may cease to be valid in a number of scenarios, including: + +For all these cases, you should remove this registration ID from the 3rd-party server and stop using it to send +messages. +
Happens when error code is NotRegistered.
+
Message Too Big
+
The total size of the payload data that is included in a message can't exceed 4096 bytes. Note that this includes both the size of the keys as well as the values. +
Happens when error code is MessageTooBig.
+
Authentication Error
+
The sender account that you're trying to use to send a message couldn't be authenticated. Possible causes are: request could not be parsed as JSON, or it contained invalid fields (for instance, passing a string where a number was expected). The exact failure reason is described in the response and the problem should be addressed before the request can be retried. Possible causes are: authorization header missing or with invalid syntax, invalid project ID sent as key, key valid but with GCM service disabled, and so on. Check that the Sender Auth Token you're sending inside the Authorization header is the correct API key associated with your project. +
Happens when the HTTP status code is 401. +
+
Internal Server Error/Timeout
+
The server encountered an error while trying to process the request or couldn't finish in time. You can retry the same request, but you MUST obey the following requirements: + +Senders that cause problems risk being blacklisted. +
Happens when the HTTP status code is 500 or 503; or when the error field of a JSON object in the results array is Unavailable. +
+
+

Example responses

+

This section shows a few examples of responses indicating messages that were processed successfully. See Example requests for the requests these responses are based on.

+

Here is a simple case of a JSON message successfully sent to one recipient without canonical IDs in the response:

+
{ "multicast_id": 108,
+  "success": 1,
+  "failure": 0,
+  "canonical_ids": 0,
+  "results": [
+    { "message_id": "1:08" }
+  ]
+}
+ +

Or if the request was in plain-text format:

+
id=1:08
+
+ +

Here are JSON results for 6 recipients (IDs 4, 8, 15, 16, 23, and 42 respectively) with 3 messages successfully processed, 1 canonical registration ID returned, and 3 errors:

+
{ "multicast_id": 216,
+  "success": 3,
+  "failure": 3,
+  "canonical_ids": 1,
+  "results": [
+    { "message_id": "1:0408" },
+    { "error": "Unavailable" },
+    { "error": "InvalidRegistration" },
+    { "message_id": "1:1516" },
+    { "message_id": "1:2342", "registration_id": "32" },
+    { "error": "NotRegistered"}
+  ]
+}
+
+

In this example:

+ +

Or if just the 4th message above was sent using plain-text format:

+
Error=InvalidRegistration
+
+

If the 5th message above was also sent using plain-text format:

+
id=1:2342
+registration_id=32
+
+ + +

Viewing statistics

+ +

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

+
    +
  1. Go to play.google.com/apps/publish.
  2. +
  3. Login with your developer account. +

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

  4. +
  5. Click on the "statistics" link next to the app for which you want to view GCM stats. +

    Now you are on the statistics page.

  6. +
  7. Go to the drop-down menu and select the GCM metric you want to view. +
  8. +
+

Examples

+

See the GCM Demo Application document.

+ diff --git a/docs/html/guide/google/gcm/gs.jd b/docs/html/guide/google/gcm/gs.jd new file mode 100644 index 0000000000000..5e426c2303b8a --- /dev/null +++ b/docs/html/guide/google/gcm/gs.jd @@ -0,0 +1,203 @@ +page.title=GCM: Getting Started +@jd:body + +
+
+ +

Quickview

+ + + + +

In this document

+ +
    +
  1. Creating a Google API Project
  2. +
  3. Enabling the GCM Service
  4. +
  5. Obtaining an API Key
  6. +
  7. Installing the Helper Libraries
  8. +
  9. Writing the Android Application +
  10. Writing the Server-side Application
  11. +
+ +
+
+ +

This document describes how to write an Android application and the server-side logic, using the helper libraries (client and server) provided by GCM.

+ + +

Creating a Google API project

+

To create a Google API project:

+
    +
  1. Open the Google APIs Console page. +
  2. +
  3. If you haven't created an API project yet, this page will prompt you to do so: +

    +

    Note: If you already have existing projects, the first page you see will be the Dashboard page. From there you can create a new project by opening the project drop-down menu (upper left corner) and choosing Other projects > Create.

  4. +
  5. Click Create project. + Your browser URL will change to something like:
  6. + +
     https://code.google.com/apis/console/#project:4815162342
    + +
  7. Take note of the value after #project: (4815162342 in this example). This is your project ID, and it will be used later on as the GCM sender ID.
  8. + +
+

Enabling the GCM Service

+

To enable the GCM service:

+
    +
  1. In the main Google APIs Console page, select Services.
  2. +
  3. Turn the Google Cloud Messaging toggle to ON.
  4. +
  5. In the Terms of Service page, accept the terms. +
  6. +
+

Obtaining an API Key

+

To obtain an API key:

+
    +
  1. In the main Google APIs Console page, select API Access. You will see a screen that resembles the following:

  2. + +
    +
    + +
    +
    + +
  3. Click Create new Server key. The following screen appears:

  4. + +
    +
    + +
    +
    + +
  5. Click Create:

  6. + +
    +
    + +
    +
    + + +
+

Take note of the API key value (YourKeyWillBeShownHere) in this example, as it will be used later on.

+

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.

+ +

Install the Helper Libraries

+

To perform the steps described in the following sections, you must first install the helper libraries (reference: client and server). From the SDK Manager, install Extras > Google Cloud Messaging for Android Library. This creates a gcm directory under YOUR_SDK_ROOT/extras/google/ containing these subdirectories: gcm-client, gcm-demo-appengine, gcm-demo-client, gcm-demo-server, and gcm-server.

+

Writing the Android Application

+

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

+

Step 1: Copy the gcm.jar file into your application classpath

+

To write your Android application, first copy the gcm.jar file from the SDK's gcm-client/dist directory to your application classpath.

+

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

+
    +
  1. GCM requires Android 2.2 or later, so if your application cannot work without GCM, add the following line, where xx is the latest target SDK version:
  2. + +
    <uses-sdk android:minSdkVersion="8" android:targetSdkVersion="xx"/>
    + +
  3. Declare and use a custom permission so only this application can receive GCM messages:
    +
  4. + +
    <permission android:name="my_app_package.permission.C2D_MESSAGE" android:protectionLevel="signature" />
    +<uses-permission android:name="my_app_package.permission.C2D_MESSAGE" /> 
    +

    This permission must be called my_app_package.permission.C2D_MESSAGE (where my_app_package is the package name of your app as defined by the manifest tag), otherwise it will not work.

    +

    Note: This permission is not required if you are targeting your application to 4.1 or above (i.e., minSdkVersion 16)

    + +
  5. Add the permission to receive GCM messages:
  6. + +
    <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
    + +
  7. Add the following broadcast receiver:
  8. + +
    <receiver android:name="com.google.android.gcm.GCMBroadcastReceiver" 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="my_app_package" />
    +  </intent-filter>
    +</receiver>
    +

    This broadcast receiver is responsible for handling the 2 intents that can be sent by GCM (com.google.android.c2dm.intent.RECEIVE and com.google.android.c2dm.intent.REGISTRATION) and should be defined in the manifest (rather than programmatically) so that these intents can be received even if the application is not running. By setting the com.google.android.c2dm.permission.SEND permission, you are ensuring that only intents sent by the GCM system framework are sent to the receiver (a regular application cannot issue intents with that permission).

    +

    Notice that android:name in the category tag must be replaced by your application's package name (and the category tag is not required for applications targeted to minSdkVersion 16 and higher).
    +

    + +
  9. Add the following intent service:
  10. + + +
    <service android:name=".GCMIntentService" />
    + +
+

This intent service will be called by the GCMBroadcastReceiver (which is is provided by GCM library), as shown in the next step. It must be named my_app_package.GCMIntentService, unless you use a subclass of GCMBroadcastReceiver that overrides the method used to name the service.

+


+ Step 3: Write the my_app_package.GCMIntentService class

+

Next write the my_app_package.GCMIntentService class, overriding the following callback methods (which are called by GCMBroadcastReceiver):
+

+ + +

Note: The methods above run in the intent service's thread and hence are free to make network calls without the risk of blocking the UI thread.

+ +

Step 4: Write your application's main activity

+Add the following import statement in your application's main activity: +
import com.google.android.gcm.GCMRegistrar;
+

In the onCreate() method, add the following code:

+
GCMRegistrar.checkDevice(this);
+GCMRegistrar.checkManifest(this);
+final String regId = GCMRegistrar.getRegistrationId(this);
+if (regId.equals("")) {
+  GCMRegistrar.register(this, SENDER_ID);
+} else {
+  Log.v(TAG, "Already registered");
+}
+

The checkDevice() method verifies that the device supports GCM and throws an exception if it does not (for instance, if it is an emulator that does not contain the Google APIs). Similarly, the checkManifest() method verifies that the application manifest contains meets all the requirements described in Writing the Android Application (this method is only necessary when you are developing the application; once the application is ready to be published, you can remove it).

+ +

Once the sanity checks are done, the device calls GCMRegsistrar.register() to register the device, passing the SENDER_ID you got when you signed up for GCM. But since the GCMRegistrar singleton keeps track of the registration ID upon the arrival of registration intents, you can call GCMRegistrar.getRegistrationId() first to check if the device is already registered.

+

Note: It is possible that the device was successfully registered to GCM but failed to send the registration ID to your server, in which case you should retry. See Advanced Topics for more details on how to handle this scenario.

+ +

Writing the Server-side Application

+ +

To write the server-side application:

+
    +
  1. Copy the gcm-server.jar file from the SDK's gcm-server/dist directory to your server classpath.
  2. +
  3. Create a servlet (or other server-side mechanism) that can be used by the Android application to send the registration ID received by GCM . The application might also need to send other information—such as the user's email address or username—so that the server can associate the registration ID with the user owning the device.
  4. +
  5. Similarly, create a servlet used to unregister registration IDs.
    +
  6. +
  7. When the server needs to send a message to the device, it can use the com.google.android.gcm.server.Sender helper class from the GCM library. For example:
  8. +
+ +
import com.google.android.gcm.server.*;
+
+Sender sender = new Sender(myApiKey);
+Message message = new Message.Builder(regId).build();
+Result result = sender.send(message, 5);
+ +

The snippet above does the following: +

+

It's now necessary to parse the result and take the proper action in the following cases:

+ +

Here's a code snippet that handles these 2 conditions:

+
+if (result.getMessageId() != null) {
+ String canonicalRegId = result.getCanonicalRegistrationId();
+ if (canonicalRegId != null) {
+   // same device has more than on registration ID: update database
+ }
+} else {
+ String error = result.getErrorCodeName();
+ if (error.equals(Constants.ERROR_NOT_REGISTERED)) {
+   // application has been removed from device - unregister database
+ }
+}
diff --git a/docs/html/guide/google/gcm/index.jd b/docs/html/guide/google/gcm/index.jd new file mode 100644 index 0000000000000..cba8d0b19d0f3 --- /dev/null +++ b/docs/html/guide/google/gcm/index.jd @@ -0,0 +1,25 @@ +page.title=Google Cloud Messaging for Android +@jd:body + + +

+

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.

+ +

To learn more about GCM, read the following documents:

+ +
+
Getting Started
+
Read this document to learn the basic steps involved in developing Android applications based on GCM.
+
Architectural Overview
+
Read this document for a description of the underlying concepts and architecture in GCM.
+
Demo App Tutorial
+
Read this document to walk through setting up and running the GCM demo app.
+
Advanced Topics
+
Read this document to get a more in-depth understanding of key GCM features.
+
Migration
+
Read this document if you are a C2DM developer moving to GCM.
+
+ +

GCM also provides helper libraries for client and server development.

+ + diff --git a/docs/html/guide/google/gcm/server-javadoc/allclasses-frame.html b/docs/html/guide/google/gcm/server-javadoc/allclasses-frame.html new file mode 100644 index 0000000000000..d2fe43d85855e --- /dev/null +++ b/docs/html/guide/google/gcm/server-javadoc/allclasses-frame.html @@ -0,0 +1,43 @@ + + + + + + +All Classes + + + + + + + + + + + +All Classes +
+ + + + + +
Constants +
+InvalidRequestException +
+Message +
+Message.Builder +
+MulticastResult +
+Result +
+Sender +
+
+ + + diff --git a/docs/html/guide/google/gcm/server-javadoc/allclasses-noframe.html b/docs/html/guide/google/gcm/server-javadoc/allclasses-noframe.html new file mode 100644 index 0000000000000..0f0dc961ff5a9 --- /dev/null +++ b/docs/html/guide/google/gcm/server-javadoc/allclasses-noframe.html @@ -0,0 +1,43 @@ + + + + + + +All Classes + + + + + + + + + + + +All Classes +
+ + + + + +
Constants +
+InvalidRequestException +
+Message +
+Message.Builder +
+MulticastResult +
+Result +
+Sender +
+
+ + + diff --git a/docs/html/guide/google/gcm/server-javadoc/com/google/android/gcm/server/Constants.html b/docs/html/guide/google/gcm/server-javadoc/com/google/android/gcm/server/Constants.html new file mode 100644 index 0000000000000..09ac01162be23 --- /dev/null +++ b/docs/html/guide/google/gcm/server-javadoc/com/google/android/gcm/server/Constants.html @@ -0,0 +1,764 @@ + + + + + + +Constants + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +com.google.android.gcm.server +
+Class Constants

+
+java.lang.Object
+  extended by com.google.android.gcm.server.Constants
+
+
+
+
public final class Constants
extends java.lang.Object
+ + +

+Constants used on GCM service communication. +

+ +

+


+ +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Field Summary
+static java.lang.StringERROR_DEVICE_QUOTA_EXCEEDED + +
+          Too many messages sent by the sender to a specific device.
+static java.lang.StringERROR_INVALID_REGISTRATION + +
+          Bad registration_id.
+static java.lang.StringERROR_MESSAGE_TOO_BIG + +
+          The payload of the message is too big, see the limitations.
+static java.lang.StringERROR_MISMATCH_SENDER_ID + +
+          The sender_id contained in the registration_id does not match the + sender_id used to register with the GCM servers.
+static java.lang.StringERROR_MISSING_COLLAPSE_KEY + +
+          Collapse key is required.
+static java.lang.StringERROR_MISSING_REGISTRATION + +
+          Missing registration_id.
+static java.lang.StringERROR_NOT_REGISTERED + +
+          The user has uninstalled the application or turned off notifications.
+static java.lang.StringERROR_QUOTA_EXCEEDED + +
+          Too many messages sent by the sender.
+static java.lang.StringERROR_UNAVAILABLE + +
+          Used to indicate that a particular message could not be sent because + the GCM servers were not available.
+static java.lang.StringGCM_SEND_ENDPOINT + +
+          Endpoint for sending messages.
+static java.lang.StringJSON_CANONICAL_IDS + +
+          JSON-only field representing the number of messages with a canonical + registration id.
+static java.lang.StringJSON_ERROR + +
+          JSON-only field representing the error field of an individual request.
+static java.lang.StringJSON_FAILURE + +
+          JSON-only field representing the number of failed messages.
+static java.lang.StringJSON_MESSAGE_ID + +
+          JSON-only field sent by GCM when a message was successfully sent.
+static java.lang.StringJSON_MULTICAST_ID + +
+          JSON-only field representing the id of the multicast request.
+static java.lang.StringJSON_PAYLOAD + +
+          JSON-only field representing the payload data.
+static java.lang.StringJSON_REGISTRATION_IDS + +
+          JSON-only field representing the registration ids.
+static java.lang.StringJSON_RESULTS + +
+          JSON-only field representing the result of each individual request.
+static java.lang.StringJSON_SUCCESS + +
+          JSON-only field representing the number of successful messages.
+static java.lang.StringPARAM_COLLAPSE_KEY + +
+          HTTP parameter for collapse key.
+static java.lang.StringPARAM_DELAY_WHILE_IDLE + +
+          HTTP parameter for delaying the message delivery if the device is idle.
+static java.lang.StringPARAM_PAYLOAD_PREFIX + +
+          Prefix to HTTP parameter used to pass key-values in the message payload.
+static java.lang.StringPARAM_REGISTRATION_ID + +
+          HTTP parameter for registration id.
+static java.lang.StringPARAM_TIME_TO_LIVE + +
+          Prefix to HTTP parameter used to set the message time-to-live.
+static java.lang.StringTOKEN_CANONICAL_REG_ID + +
+          Token returned by GCM when the requested registration id has a canonical + value.
+static java.lang.StringTOKEN_ERROR + +
+          Token returned by GCM when there was an error sending a message.
+static java.lang.StringTOKEN_MESSAGE_ID + +
+          Token returned by GCM when a message was successfully sent.
+  + + + + + + + +
+Method Summary
+  + + + + + + + +
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
+  +

+ + + + + + + + +
+Field Detail
+ +

+GCM_SEND_ENDPOINT

+
+public static final java.lang.String GCM_SEND_ENDPOINT
+
+
Endpoint for sending messages. +

+

+
See Also:
Constant Field Values
+
+
+ +

+PARAM_REGISTRATION_ID

+
+public static final java.lang.String PARAM_REGISTRATION_ID
+
+
HTTP parameter for registration id. +

+

+
See Also:
Constant Field Values
+
+
+ +

+PARAM_COLLAPSE_KEY

+
+public static final java.lang.String PARAM_COLLAPSE_KEY
+
+
HTTP parameter for collapse key. +

+

+
See Also:
Constant Field Values
+
+
+ +

+PARAM_DELAY_WHILE_IDLE

+
+public static final java.lang.String PARAM_DELAY_WHILE_IDLE
+
+
HTTP parameter for delaying the message delivery if the device is idle. +

+

+
See Also:
Constant Field Values
+
+
+ +

+PARAM_PAYLOAD_PREFIX

+
+public static final java.lang.String PARAM_PAYLOAD_PREFIX
+
+
Prefix to HTTP parameter used to pass key-values in the message payload. +

+

+
See Also:
Constant Field Values
+
+
+ +

+PARAM_TIME_TO_LIVE

+
+public static final java.lang.String PARAM_TIME_TO_LIVE
+
+
Prefix to HTTP parameter used to set the message time-to-live. +

+

+
See Also:
Constant Field Values
+
+
+ +

+ERROR_QUOTA_EXCEEDED

+
+public static final java.lang.String ERROR_QUOTA_EXCEEDED
+
+
Too many messages sent by the sender. Retry after a while. +

+

+
See Also:
Constant Field Values
+
+
+ +

+ERROR_DEVICE_QUOTA_EXCEEDED

+
+public static final java.lang.String ERROR_DEVICE_QUOTA_EXCEEDED
+
+
Too many messages sent by the sender to a specific device. + Retry after a while. +

+

+
See Also:
Constant Field Values
+
+
+ +

+ERROR_MISSING_REGISTRATION

+
+public static final java.lang.String ERROR_MISSING_REGISTRATION
+
+
Missing registration_id. + Sender should always add the registration_id to the request. +

+

+
See Also:
Constant Field Values
+
+
+ +

+ERROR_INVALID_REGISTRATION

+
+public static final java.lang.String ERROR_INVALID_REGISTRATION
+
+
Bad registration_id. Sender should remove this registration_id. +

+

+
See Also:
Constant Field Values
+
+
+ +

+ERROR_MISMATCH_SENDER_ID

+
+public static final java.lang.String ERROR_MISMATCH_SENDER_ID
+
+
The sender_id contained in the registration_id does not match the + sender_id used to register with the GCM servers. +

+

+
See Also:
Constant Field Values
+
+
+ +

+ERROR_NOT_REGISTERED

+
+public static final java.lang.String ERROR_NOT_REGISTERED
+
+
The user has uninstalled the application or turned off notifications. + Sender should stop sending messages to this device and delete the + registration_id. The client needs to re-register with the GCM servers to + receive notifications again. +

+

+
See Also:
Constant Field Values
+
+
+ +

+ERROR_MESSAGE_TOO_BIG

+
+public static final java.lang.String ERROR_MESSAGE_TOO_BIG
+
+
The payload of the message is too big, see the limitations. + Reduce the size of the message. +

+

+
See Also:
Constant Field Values
+
+
+ +

+ERROR_MISSING_COLLAPSE_KEY

+
+public static final java.lang.String ERROR_MISSING_COLLAPSE_KEY
+
+
Collapse key is required. Include collapse key in the request. +

+

+
See Also:
Constant Field Values
+
+
+ +

+ERROR_UNAVAILABLE

+
+public static final java.lang.String ERROR_UNAVAILABLE
+
+
Used to indicate that a particular message could not be sent because + the GCM servers were not available. Used only on JSON requests, as in + plain text requests unavailability is indicated by a 503 response. +

+

+
See Also:
Constant Field Values
+
+
+ +

+TOKEN_MESSAGE_ID

+
+public static final java.lang.String TOKEN_MESSAGE_ID
+
+
Token returned by GCM when a message was successfully sent. +

+

+
See Also:
Constant Field Values
+
+
+ +

+TOKEN_CANONICAL_REG_ID

+
+public static final java.lang.String TOKEN_CANONICAL_REG_ID
+
+
Token returned by GCM when the requested registration id has a canonical + value. +

+

+
See Also:
Constant Field Values
+
+
+ +

+TOKEN_ERROR

+
+public static final java.lang.String TOKEN_ERROR
+
+
Token returned by GCM when there was an error sending a message. +

+

+
See Also:
Constant Field Values
+
+
+ +

+JSON_REGISTRATION_IDS

+
+public static final java.lang.String JSON_REGISTRATION_IDS
+
+
JSON-only field representing the registration ids. +

+

+
See Also:
Constant Field Values
+
+
+ +

+JSON_PAYLOAD

+
+public static final java.lang.String JSON_PAYLOAD
+
+
JSON-only field representing the payload data. +

+

+
See Also:
Constant Field Values
+
+
+ +

+JSON_SUCCESS

+
+public static final java.lang.String JSON_SUCCESS
+
+
JSON-only field representing the number of successful messages. +

+

+
See Also:
Constant Field Values
+
+
+ +

+JSON_FAILURE

+
+public static final java.lang.String JSON_FAILURE
+
+
JSON-only field representing the number of failed messages. +

+

+
See Also:
Constant Field Values
+
+
+ +

+JSON_CANONICAL_IDS

+
+public static final java.lang.String JSON_CANONICAL_IDS
+
+
JSON-only field representing the number of messages with a canonical + registration id. +

+

+
See Also:
Constant Field Values
+
+
+ +

+JSON_MULTICAST_ID

+
+public static final java.lang.String JSON_MULTICAST_ID
+
+
JSON-only field representing the id of the multicast request. +

+

+
See Also:
Constant Field Values
+
+
+ +

+JSON_RESULTS

+
+public static final java.lang.String JSON_RESULTS
+
+
JSON-only field representing the result of each individual request. +

+

+
See Also:
Constant Field Values
+
+
+ +

+JSON_ERROR

+
+public static final java.lang.String JSON_ERROR
+
+
JSON-only field representing the error field of an individual request. +

+

+
See Also:
Constant Field Values
+
+
+ +

+JSON_MESSAGE_ID

+
+public static final java.lang.String JSON_MESSAGE_ID
+
+
JSON-only field sent by GCM when a message was successfully sent. +

+

+
See Also:
Constant Field Values
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + diff --git a/docs/html/guide/google/gcm/server-javadoc/com/google/android/gcm/server/InvalidRequestException.html b/docs/html/guide/google/gcm/server-javadoc/com/google/android/gcm/server/InvalidRequestException.html new file mode 100644 index 0000000000000..4b3271c753ec0 --- /dev/null +++ b/docs/html/guide/google/gcm/server-javadoc/com/google/android/gcm/server/InvalidRequestException.html @@ -0,0 +1,310 @@ + + + + + + +InvalidRequestException + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +com.google.android.gcm.server +
+Class InvalidRequestException

+
+java.lang.Object
+  extended by java.lang.Throwable
+      extended by java.lang.Exception
+          extended by java.io.IOException
+              extended by com.google.android.gcm.server.InvalidRequestException
+
+
+
All Implemented Interfaces:
java.io.Serializable
+
+
+
+
public final class InvalidRequestException
extends java.io.IOException
+ + +

+Exception thrown when GCM returned an error due to an invalid request. +

+ This is equivalent to GCM posts that return an HTTP error different of 200. +

+ +

+

+
See Also:
Serialized Form
+
+ +

+ + + + + + + + + + + + + + +
+Constructor Summary
InvalidRequestException(int status) + +
+           
InvalidRequestException(int status, + java.lang.String description) + +
+           
+  + + + + + + + + + + + + + + + +
+Method Summary
+ java.lang.StringgetDescription() + +
+          Gets the error description.
+ intgetHttpStatusCode() + +
+          Gets the HTTP Status Code.
+  + + + + + + + +
Methods inherited from class java.lang.Throwable
fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
+  + + + + + + + +
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
+  +

+ + + + + + + + +
+Constructor Detail
+ +

+InvalidRequestException

+
+public InvalidRequestException(int status)
+
+
+
+ +

+InvalidRequestException

+
+public InvalidRequestException(int status,
+                               java.lang.String description)
+
+
+ + + + + + + + +
+Method Detail
+ +

+getHttpStatusCode

+
+public int getHttpStatusCode()
+
+
Gets the HTTP Status Code. +

+

+
+
+
+
+ +

+getDescription

+
+public java.lang.String getDescription()
+
+
Gets the error description. +

+

+
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + diff --git a/docs/html/guide/google/gcm/server-javadoc/com/google/android/gcm/server/Message.Builder.html b/docs/html/guide/google/gcm/server-javadoc/com/google/android/gcm/server/Message.Builder.html new file mode 100644 index 0000000000000..5952e87ae04f5 --- /dev/null +++ b/docs/html/guide/google/gcm/server-javadoc/com/google/android/gcm/server/Message.Builder.html @@ -0,0 +1,337 @@ + + + + + + +Message.Builder + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +com.google.android.gcm.server +
+Class Message.Builder

+
+java.lang.Object
+  extended by com.google.android.gcm.server.Message.Builder
+
+
+
Enclosing class:
Message
+
+
+
+
public static final class Message.Builder
extends java.lang.Object
+ + +

+


+ +

+ + + + + + + + + + + +
+Constructor Summary
Message.Builder() + +
+           
+  + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Method Summary
+ Message.BuilderaddData(java.lang.String key, + java.lang.String value) + +
+          Adds a key/value pair to the payload data.
+ Messagebuild() + +
+           
+ Message.BuildercollapseKey(java.lang.String value) + +
+          Sets the collapseKey property.
+ Message.BuilderdelayWhileIdle(boolean value) + +
+          Sets the delayWhileIdle property (default value is false).
+ Message.BuildertimeToLive(int value) + +
+          Sets the time to live, in seconds.
+  + + + + + + + +
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
+  +

+ + + + + + + + +
+Constructor Detail
+ +

+Message.Builder

+
+public Message.Builder()
+
+
+ + + + + + + + +
+Method Detail
+ +

+collapseKey

+
+public Message.Builder collapseKey(java.lang.String value)
+
+
Sets the collapseKey property. +

+

+
+
+
+
+ +

+delayWhileIdle

+
+public Message.Builder delayWhileIdle(boolean value)
+
+
Sets the delayWhileIdle property (default value is false). +

+

+
+
+
+
+ +

+timeToLive

+
+public Message.Builder timeToLive(int value)
+
+
Sets the time to live, in seconds. +

+

+
+
+
+
+ +

+addData

+
+public Message.Builder addData(java.lang.String key,
+                               java.lang.String value)
+
+
Adds a key/value pair to the payload data. +

+

+
+
+
+
+ +

+build

+
+public Message build()
+
+
+
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + diff --git a/docs/html/guide/google/gcm/server-javadoc/com/google/android/gcm/server/Message.html b/docs/html/guide/google/gcm/server-javadoc/com/google/android/gcm/server/Message.html new file mode 100644 index 0000000000000..0773686b53afd --- /dev/null +++ b/docs/html/guide/google/gcm/server-javadoc/com/google/android/gcm/server/Message.html @@ -0,0 +1,369 @@ + + + + + + +Message + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +com.google.android.gcm.server +
+Class Message

+
+java.lang.Object
+  extended by com.google.android.gcm.server.Message
+
+
+
All Implemented Interfaces:
java.io.Serializable
+
+
+
+
public final class Message
extends java.lang.Object
implements java.io.Serializable
+ + +

+GCM message. + +

+ Instances of this class are immutable and should be created using a + Message.Builder. Examples: + + Simplest message: +


+ Message message = new Message.Builder().build();
+ 
+ + Message with optional attributes: +

+ Message message = new Message.Builder()
+    .collapseKey(collapseKey)
+    .timeToLive(3)
+    .delayWhileIdle(true)
+    .build();
+ 
+ + Message with optional attributes and payload data: +

+ Message message = new Message.Builder()
+    .collapseKey(collapseKey)
+    .timeToLive(3)
+    .delayWhileIdle(true)
+    .addData("key1", "value1")
+    .addData("key2", "value2")
+    .build();
+ 
+

+ +

+

+
See Also:
Serialized Form
+
+ +

+ + + + + + + + + + + +
+Nested Class Summary
+static classMessage.Builder + +
+           
+  + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Method Summary
+ java.lang.StringgetCollapseKey() + +
+          Gets the collapse key.
+ java.util.Map<java.lang.String,java.lang.String>getData() + +
+          Gets the payload data, which is immutable.
+ java.lang.IntegergetTimeToLive() + +
+          Gets the time to live (in seconds).
+ java.lang.BooleanisDelayWhileIdle() + +
+          Gets the delayWhileIdle flag.
+ java.lang.StringtoString() + +
+           
+  + + + + + + + +
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
+  +

+ + + + + + + + +
+Method Detail
+ +

+getCollapseKey

+
+public java.lang.String getCollapseKey()
+
+
Gets the collapse key. +

+

+
+
+
+
+
+
+
+ +

+isDelayWhileIdle

+
+public java.lang.Boolean isDelayWhileIdle()
+
+
Gets the delayWhileIdle flag. +

+

+
+
+
+
+
+
+
+ +

+getTimeToLive

+
+public java.lang.Integer getTimeToLive()
+
+
Gets the time to live (in seconds). +

+

+
+
+
+
+
+
+
+ +

+getData

+
+public java.util.Map<java.lang.String,java.lang.String> getData()
+
+
Gets the payload data, which is immutable. +

+

+
+
+
+
+
+
+
+ +

+toString

+
+public java.lang.String toString()
+
+
+
Overrides:
toString in class java.lang.Object
+
+
+
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + diff --git a/docs/html/guide/google/gcm/server-javadoc/com/google/android/gcm/server/MulticastResult.html b/docs/html/guide/google/gcm/server-javadoc/com/google/android/gcm/server/MulticastResult.html new file mode 100644 index 0000000000000..f9df609161a3d --- /dev/null +++ b/docs/html/guide/google/gcm/server-javadoc/com/google/android/gcm/server/MulticastResult.html @@ -0,0 +1,397 @@ + + + + + + +MulticastResult + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +com.google.android.gcm.server +
+Class MulticastResult

+
+java.lang.Object
+  extended by com.google.android.gcm.server.MulticastResult
+
+
+
All Implemented Interfaces:
java.io.Serializable
+
+
+
+
public final class MulticastResult
extends java.lang.Object
implements java.io.Serializable
+ + +

+Result of a GCM multicast message request . +

+ +

+

+
See Also:
Serialized Form
+
+ +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Method Summary
+ intgetCanonicalIds() + +
+          Gets the number of successful messages that also returned a canonical + registration id.
+ intgetFailure() + +
+          Gets the number of failed messages.
+ longgetMulticastId() + +
+          Gets the multicast id.
+ java.util.List<Result>getResults() + +
+          Gets the results of each individual message, which is immutable.
+ java.util.List<java.lang.Long>getRetryMulticastIds() + +
+          Gets additional ids if more than one multicast message was sent.
+ intgetSuccess() + +
+          Gets the number of successful messages.
+ intgetTotal() + +
+          Gets the total number of messages sent, regardless of the status.
+ java.lang.StringtoString() + +
+           
+  + + + + + + + +
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
+  +

+ + + + + + + + +
+Method Detail
+ +

+getMulticastId

+
+public long getMulticastId()
+
+
Gets the multicast id. +

+

+
+
+
+
+
+
+
+ +

+getSuccess

+
+public int getSuccess()
+
+
Gets the number of successful messages. +

+

+
+
+
+
+
+
+
+ +

+getTotal

+
+public int getTotal()
+
+
Gets the total number of messages sent, regardless of the status. +

+

+
+
+
+
+
+
+
+ +

+getFailure

+
+public int getFailure()
+
+
Gets the number of failed messages. +

+

+
+
+
+
+
+
+
+ +

+getCanonicalIds

+
+public int getCanonicalIds()
+
+
Gets the number of successful messages that also returned a canonical + registration id. +

+

+
+
+
+
+
+
+
+ +

+getResults

+
+public java.util.List<Result> getResults()
+
+
Gets the results of each individual message, which is immutable. +

+

+
+
+
+
+
+
+
+ +

+getRetryMulticastIds

+
+public java.util.List<java.lang.Long> getRetryMulticastIds()
+
+
Gets additional ids if more than one multicast message was sent. +

+

+
+
+
+
+
+
+
+ +

+toString

+
+public java.lang.String toString()
+
+
+
Overrides:
toString in class java.lang.Object
+
+
+
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + diff --git a/docs/html/guide/google/gcm/server-javadoc/com/google/android/gcm/server/Result.html b/docs/html/guide/google/gcm/server-javadoc/com/google/android/gcm/server/Result.html new file mode 100644 index 0000000000000..14d4b34ce4a32 --- /dev/null +++ b/docs/html/guide/google/gcm/server-javadoc/com/google/android/gcm/server/Result.html @@ -0,0 +1,322 @@ + + + + + + +Result + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +com.google.android.gcm.server +
+Class Result

+
+java.lang.Object
+  extended by com.google.android.gcm.server.Result
+
+
+
All Implemented Interfaces:
java.io.Serializable
+
+
+
+
public final class Result
extends java.lang.Object
implements java.io.Serializable
+ + +

+Result of a GCM message request that returned HTTP status code 200. + +

+ If the message is successfully created, the getMessageId() returns + the message id and getErrorCodeName() returns null; + otherwise, getMessageId() returns null and + getErrorCodeName() returns the code of the error. + +

+ There are cases when a request is accept and the message successfully + created, but GCM has a canonical registration id for that device. In this + case, the server should update the registration id to avoid rejected requests + in the future. + +

+ In a nutshell, the workflow to handle a result is: +

+   - Call getMessageId():
+     - null means error, call getErrorCodeName()
+     - non-null means the message was created:
+       - Call getCanonicalRegistrationId()
+         - if it returns null, do nothing.
+         - otherwise, update the server datastore with the new id.
+ 
+

+ +

+

+
See Also:
Serialized Form
+
+ +

+ + + + + + + + + + + + + + + + + + + + + + + + +
+Method Summary
+ java.lang.StringgetCanonicalRegistrationId() + +
+          Gets the canonical registration id, if any.
+ java.lang.StringgetErrorCodeName() + +
+          Gets the error code, if any.
+ java.lang.StringgetMessageId() + +
+          Gets the message id, if any.
+ java.lang.StringtoString() + +
+           
+  + + + + + + + +
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
+  +

+ + + + + + + + +
+Method Detail
+ +

+getMessageId

+
+public java.lang.String getMessageId()
+
+
Gets the message id, if any. +

+

+
+
+
+
+
+
+
+ +

+getCanonicalRegistrationId

+
+public java.lang.String getCanonicalRegistrationId()
+
+
Gets the canonical registration id, if any. +

+

+
+
+
+
+
+
+
+ +

+getErrorCodeName

+
+public java.lang.String getErrorCodeName()
+
+
Gets the error code, if any. +

+

+
+
+
+
+
+
+
+ +

+toString

+
+public java.lang.String toString()
+
+
+
Overrides:
toString in class java.lang.Object
+
+
+
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + diff --git a/docs/html/guide/google/gcm/server-javadoc/com/google/android/gcm/server/Sender.html b/docs/html/guide/google/gcm/server-javadoc/com/google/android/gcm/server/Sender.html new file mode 100644 index 0000000000000..4f1a2ac993bfc --- /dev/null +++ b/docs/html/guide/google/gcm/server-javadoc/com/google/android/gcm/server/Sender.html @@ -0,0 +1,662 @@ + + + + + + +Sender + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +com.google.android.gcm.server +
+Class Sender

+
+java.lang.Object
+  extended by com.google.android.gcm.server.Sender
+
+
+
+
public class Sender
extends java.lang.Object
+ + +

+Helper class to send messages to the GCM service using an API Key. +

+ +

+


+ +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Field Summary
+protected static intBACKOFF_INITIAL_DELAY + +
+          Initial delay before first retry, without jitter.
+protected  java.util.logging.Loggerlogger + +
+           
+protected static intMAX_BACKOFF_DELAY + +
+          Maximum delay before a retry.
+protected  java.util.Randomrandom + +
+           
+protected static java.lang.StringUTF8 + +
+           
+  + + + + + + + + + + +
+Constructor Summary
Sender(java.lang.String key) + +
+          Default constructor.
+  + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Method Summary
+protected static voidaddParameter(java.lang.StringBuilder body, + java.lang.String name, + java.lang.String value) + +
+          Adds a new parameter to the HTTP POST body.
+protected  java.net.HttpURLConnectiongetConnection(java.lang.String url) + +
+          Gets an HttpURLConnection given an URL.
+protected static java.lang.StringgetString(java.io.InputStream stream) + +
+          Convenience method to convert an InputStream to a String.
+protected static java.lang.StringBuildernewBody(java.lang.String name, + java.lang.String value) + +
+          Creates a StringBuilder to be used as the body of an HTTP POST.
+protected static java.util.Map<java.lang.String,java.lang.String>newKeyValues(java.lang.String key, + java.lang.String value) + +
+          Creates a map with just one key-value pair.
+protected  java.net.HttpURLConnectionpost(java.lang.String url, + java.lang.String body) + +
+          Make an HTTP post to a given URL.
+protected  java.net.HttpURLConnectionpost(java.lang.String url, + java.lang.String contentType, + java.lang.String body) + +
+           
+ MulticastResultsend(Message message, + java.util.List<java.lang.String> regIds, + int retries) + +
+          Sends a message to many devices, retrying in case of unavailability.
+ Resultsend(Message message, + java.lang.String registrationId, + int retries) + +
+          Sends a message to one device, retrying in case of unavailability.
+ MulticastResultsendNoRetry(Message message, + java.util.List<java.lang.String> registrationIds) + +
+          Sends a message without retrying in case of service unavailability.
+ ResultsendNoRetry(Message message, + java.lang.String registrationId) + +
+          Sends a message without retrying in case of service unavailability.
+  + + + + + + + +
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
+  +

+ + + + + + + + +
+Field Detail
+ +

+UTF8

+
+protected static final java.lang.String UTF8
+
+
+
See Also:
Constant Field Values
+
+
+ +

+BACKOFF_INITIAL_DELAY

+
+protected static final int BACKOFF_INITIAL_DELAY
+
+
Initial delay before first retry, without jitter. +

+

+
See Also:
Constant Field Values
+
+
+ +

+MAX_BACKOFF_DELAY

+
+protected static final int MAX_BACKOFF_DELAY
+
+
Maximum delay before a retry. +

+

+
See Also:
Constant Field Values
+
+
+ +

+random

+
+protected final java.util.Random random
+
+
+
+
+
+ +

+logger

+
+protected final java.util.logging.Logger logger
+
+
+
+
+ + + + + + + + +
+Constructor Detail
+ +

+Sender

+
+public Sender(java.lang.String key)
+
+
Default constructor. +

+

+
Parameters:
key - API key obtained through the Google API Console.
+
+ + + + + + + + +
+Method Detail
+ +

+send

+
+public Result send(Message message,
+                   java.lang.String registrationId,
+                   int retries)
+            throws java.io.IOException
+
+
Sends a message to one device, retrying in case of unavailability. + +

+ Note: this method uses exponential back-off to retry in + case of service unavailability and hence could block the calling thread + for many seconds. +

+

+
Parameters:
message - message to be sent, including the device's registration id.
registrationId - device where the message will be sent.
retries - number of retries in case of service unavailability errors. +
Returns:
result of the request (see its javadoc for more details) +
Throws: +
java.lang.IllegalArgumentException - if registrationId is null. +
InvalidRequestException - if GCM didn't returned a 200 or 503 status. +
java.io.IOException - if message could not be sent.
+
+
+
+ +

+sendNoRetry

+
+public Result sendNoRetry(Message message,
+                          java.lang.String registrationId)
+                   throws java.io.IOException
+
+
Sends a message without retrying in case of service unavailability. See + send(Message, String, int) for more info. +

+

+ +
Returns:
result of the post, or null if the GCM service was + unavailable. +
Throws: +
InvalidRequestException - if GCM didn't returned a 200 or 503 status. +
java.lang.IllegalArgumentException - if registrationId is null. +
java.io.IOException
+
+
+
+ +

+send

+
+public MulticastResult send(Message message,
+                            java.util.List<java.lang.String> regIds,
+                            int retries)
+                     throws java.io.IOException
+
+
Sends a message to many devices, retrying in case of unavailability. + +

+ Note: this method uses exponential back-off to retry in + case of service unavailability and hence could block the calling thread + for many seconds. +

+

+
Parameters:
message - message to be sent.
regIds - registration id of the devices that will receive + the message.
retries - number of retries in case of service unavailability errors. +
Returns:
combined result of all requests made. +
Throws: +
java.lang.IllegalArgumentException - if registrationIds is null or + empty. +
InvalidRequestException - if GCM didn't returned a 200 or 503 status. +
java.io.IOException - if message could not be sent.
+
+
+
+ +

+sendNoRetry

+
+public MulticastResult sendNoRetry(Message message,
+                                   java.util.List<java.lang.String> registrationIds)
+                            throws java.io.IOException
+
+
Sends a message without retrying in case of service unavailability. See + send(Message, List, int) for more info. +

+

+ +
Returns:
true if the message was sent successfully, + false if it failed but could be retried. +
Throws: +
java.lang.IllegalArgumentException - if registrationIds is null or + empty. +
InvalidRequestException - if GCM didn't returned a 200 status. +
java.io.IOException - if message could not be sent or received.
+
+
+
+ +

+post

+
+protected java.net.HttpURLConnection post(java.lang.String url,
+                                          java.lang.String body)
+                                   throws java.io.IOException
+
+
Make an HTTP post to a given URL. +

+

+ +
Returns:
HTTP response. +
Throws: +
java.io.IOException
+
+
+
+ +

+post

+
+protected java.net.HttpURLConnection post(java.lang.String url,
+                                          java.lang.String contentType,
+                                          java.lang.String body)
+                                   throws java.io.IOException
+
+
+ +
Throws: +
java.io.IOException
+
+
+
+ +

+newKeyValues

+
+protected static final java.util.Map<java.lang.String,java.lang.String> newKeyValues(java.lang.String key,
+                                                                                     java.lang.String value)
+
+
Creates a map with just one key-value pair. +

+

+
+
+
+
+ +

+newBody

+
+protected static java.lang.StringBuilder newBody(java.lang.String name,
+                                                 java.lang.String value)
+
+
Creates a StringBuilder to be used as the body of an HTTP POST. +

+

+
Parameters:
name - initial parameter for the POST.
value - initial value for that parameter. +
Returns:
StringBuilder to be used an HTTP POST body.
+
+
+
+ +

+addParameter

+
+protected static void addParameter(java.lang.StringBuilder body,
+                                   java.lang.String name,
+                                   java.lang.String value)
+
+
Adds a new parameter to the HTTP POST body. +

+

+
Parameters:
body - HTTP POST body
name - parameter's name
value - parameter's value
+
+
+
+ +

+getConnection

+
+protected java.net.HttpURLConnection getConnection(java.lang.String url)
+                                            throws java.io.IOException
+
+
Gets an HttpURLConnection given an URL. +

+

+ +
Throws: +
java.io.IOException
+
+
+
+ +

+getString

+
+protected static java.lang.String getString(java.io.InputStream stream)
+                                     throws java.io.IOException
+
+
Convenience method to convert an InputStream to a String. + +

+ If the stream ends in a newline character, it will be stripped. +

+

+ +
Throws: +
java.io.IOException
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + diff --git a/docs/html/guide/google/gcm/server-javadoc/com/google/android/gcm/server/package-frame.html b/docs/html/guide/google/gcm/server-javadoc/com/google/android/gcm/server/package-frame.html new file mode 100644 index 0000000000000..8312f46792965 --- /dev/null +++ b/docs/html/guide/google/gcm/server-javadoc/com/google/android/gcm/server/package-frame.html @@ -0,0 +1,53 @@ + + + + + + +com.google.android.gcm.server + + + + + + + + + + + +com.google.android.gcm.server + + + + +
+Classes  + +
+Constants +
+Message +
+Message.Builder +
+MulticastResult +
+Result +
+Sender
+ + + + + + +
+Exceptions  + +
+InvalidRequestException
+ + + + diff --git a/docs/html/guide/google/gcm/server-javadoc/com/google/android/gcm/server/package-summary.html b/docs/html/guide/google/gcm/server-javadoc/com/google/android/gcm/server/package-summary.html new file mode 100644 index 0000000000000..27b05645858a1 --- /dev/null +++ b/docs/html/guide/google/gcm/server-javadoc/com/google/android/gcm/server/package-summary.html @@ -0,0 +1,187 @@ + + + + + + +com.google.android.gcm.server + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+

+Package com.google.android.gcm.server +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Class Summary
ConstantsConstants used on GCM service communication.
MessageGCM message.
Message.Builder 
MulticastResultResult of a GCM multicast message request .
ResultResult of a GCM message request that returned HTTP status code 200.
SenderHelper class to send messages to the GCM service using an API Key.
+  + +

+ + + + + + + + + +
+Exception Summary
InvalidRequestExceptionException thrown when GCM returned an error due to an invalid request.
+  + +

+

+
+
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + diff --git a/docs/html/guide/google/gcm/server-javadoc/com/google/android/gcm/server/package-tree.html b/docs/html/guide/google/gcm/server-javadoc/com/google/android/gcm/server/package-tree.html new file mode 100644 index 0000000000000..81efcef77867f --- /dev/null +++ b/docs/html/guide/google/gcm/server-javadoc/com/google/android/gcm/server/package-tree.html @@ -0,0 +1,156 @@ + + + + + + +com.google.android.gcm.server Class Hierarchy + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+
+

+Hierarchy For Package com.google.android.gcm.server +

+
+

+Class Hierarchy +

+ +
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + diff --git a/docs/html/guide/google/gcm/server-javadoc/constant-values.html b/docs/html/guide/google/gcm/server-javadoc/constant-values.html new file mode 100644 index 0000000000000..5efe6f5121fe9 --- /dev/null +++ b/docs/html/guide/google/gcm/server-javadoc/constant-values.html @@ -0,0 +1,356 @@ + + + + + + +Constant Field Values + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+
+

+Constant Field Values

+
+
+Contents + + + + + + +
+com.google.*
+ +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
com.google.android.gcm.server.Constants
+public static final java.lang.StringERROR_DEVICE_QUOTA_EXCEEDED"DeviceQuotaExceeded"
+public static final java.lang.StringERROR_INVALID_REGISTRATION"InvalidRegistration"
+public static final java.lang.StringERROR_MESSAGE_TOO_BIG"MessageTooBig"
+public static final java.lang.StringERROR_MISMATCH_SENDER_ID"MismatchSenderId"
+public static final java.lang.StringERROR_MISSING_COLLAPSE_KEY"MissingCollapseKey"
+public static final java.lang.StringERROR_MISSING_REGISTRATION"MissingRegistration"
+public static final java.lang.StringERROR_NOT_REGISTERED"NotRegistered"
+public static final java.lang.StringERROR_QUOTA_EXCEEDED"QuotaExceeded"
+public static final java.lang.StringERROR_UNAVAILABLE"Unavailable"
+public static final java.lang.StringGCM_SEND_ENDPOINT"https://android.googleapis.com/gcm/send"
+public static final java.lang.StringJSON_CANONICAL_IDS"canonical_ids"
+public static final java.lang.StringJSON_ERROR"error"
+public static final java.lang.StringJSON_FAILURE"failure"
+public static final java.lang.StringJSON_MESSAGE_ID"message_id"
+public static final java.lang.StringJSON_MULTICAST_ID"multicast_id"
+public static final java.lang.StringJSON_PAYLOAD"data"
+public static final java.lang.StringJSON_REGISTRATION_IDS"registration_ids"
+public static final java.lang.StringJSON_RESULTS"results"
+public static final java.lang.StringJSON_SUCCESS"success"
+public static final java.lang.StringPARAM_COLLAPSE_KEY"collapse_key"
+public static final java.lang.StringPARAM_DELAY_WHILE_IDLE"delay_while_idle"
+public static final java.lang.StringPARAM_PAYLOAD_PREFIX"data."
+public static final java.lang.StringPARAM_REGISTRATION_ID"registration_id"
+public static final java.lang.StringPARAM_TIME_TO_LIVE"time_to_live"
+public static final java.lang.StringTOKEN_CANONICAL_REG_ID"registration_id"
+public static final java.lang.StringTOKEN_ERROR"Error"
+public static final java.lang.StringTOKEN_MESSAGE_ID"id"
+ +

+ +

+ + + + + + + + + + + + + + + + + + + + + + +
com.google.android.gcm.server.Sender
+protected static final intBACKOFF_INITIAL_DELAY1000
+protected static final intMAX_BACKOFF_DELAY1024000
+protected static final java.lang.StringUTF8"UTF-8"
+ +

+ +

+


+ + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + diff --git a/docs/html/guide/google/gcm/server-javadoc/deprecated-list.html b/docs/html/guide/google/gcm/server-javadoc/deprecated-list.html new file mode 100644 index 0000000000000..00826140ecab0 --- /dev/null +++ b/docs/html/guide/google/gcm/server-javadoc/deprecated-list.html @@ -0,0 +1,142 @@ + + + + + + +Deprecated List + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+
+

+Deprecated API

+
+
+Contents + +
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + diff --git a/docs/html/guide/google/gcm/server-javadoc/help-doc.html b/docs/html/guide/google/gcm/server-javadoc/help-doc.html new file mode 100644 index 0000000000000..72f9fb2edeaa4 --- /dev/null +++ b/docs/html/guide/google/gcm/server-javadoc/help-doc.html @@ -0,0 +1,209 @@ + + + + + + +API Help + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+
+

+How This API Document Is Organized

+
+This API (Application Programming Interface) document has pages corresponding to the items in the navigation bar, described as follows.

+Package

+
+ +

+Each package has a page that contains a list of its classes and interfaces, with a summary for each. This page can contain four categories:

+
+

+Class/Interface

+
+ +

+Each class, interface, nested class and nested interface has its own separate page. Each of these pages has three sections consisting of a class/interface description, summary tables, and detailed member descriptions:

+Each summary entry contains the first sentence from the detailed description for that item. The summary entries are alphabetical, while the detailed descriptions are in the order they appear in the source code. This preserves the logical groupings established by the programmer.
+ +

+Annotation Type

+
+ +

+Each annotation type has its own separate page with the following sections:

+
+ +

+Enum

+
+ +

+Each enum has its own separate page with the following sections:

+
+

+Tree (Class Hierarchy)

+
+There is a Class Hierarchy page for all packages, plus a hierarchy for each package. Each hierarchy page contains a list of classes and a list of interfaces. The classes are organized by inheritance structure starting with java.lang.Object. The interfaces do not inherit from java.lang.Object. +
+

+Deprecated API

+
+The Deprecated API page lists all of the API that have been deprecated. A deprecated API is not recommended for use, generally due to improvements, and a replacement API is usually given. Deprecated APIs may be removed in future implementations.
+

+Index

+
+The Index contains an alphabetic list of all classes, interfaces, constructors, methods, and fields.
+

+Prev/Next

+These links take you to the next or previous class, interface, package, or related page.

+Frames/No Frames

+These links show and hide the HTML frames. All pages are available with or without frames. +

+

+Serialized Form

+Each serializable or externalizable class has a description of its serialization fields and methods. This information is of interest to re-implementors, not to developers using the API. While there is no link in the navigation bar, you can get to this information by going to any serialized class and clicking "Serialized Form" in the "See also" section of the class description. +

+

+Constant Field Values

+The Constant Field Values page lists the static final fields and their values. +

+ + +This help file applies to API documentation generated using the standard doclet. + +
+


+ + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + diff --git a/docs/html/guide/google/gcm/server-javadoc/index-all.html b/docs/html/guide/google/gcm/server-javadoc/index-all.html new file mode 100644 index 0000000000000..e6325cb8fc142 --- /dev/null +++ b/docs/html/guide/google/gcm/server-javadoc/index-all.html @@ -0,0 +1,431 @@ + + + + + + +Index + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + +
+ +
+ + + +A B C D E G I J L M N P R S T U
+

+A

+
+
addData(String, String) - +Method in class com.google.android.gcm.server.Message.Builder +
Adds a key/value pair to the payload data. +
addParameter(StringBuilder, String, String) - +Static method in class com.google.android.gcm.server.Sender +
Adds a new parameter to the HTTP POST body. +
+
+

+B

+
+
BACKOFF_INITIAL_DELAY - +Static variable in class com.google.android.gcm.server.Sender +
Initial delay before first retry, without jitter. +
build() - +Method in class com.google.android.gcm.server.Message.Builder +
  +
+
+

+C

+
+
collapseKey(String) - +Method in class com.google.android.gcm.server.Message.Builder +
Sets the collapseKey property. +
com.google.android.gcm.server - package com.google.android.gcm.server
 
Constants - Class in com.google.android.gcm.server
Constants used on GCM service communication.
+
+

+D

+
+
delayWhileIdle(boolean) - +Method in class com.google.android.gcm.server.Message.Builder +
Sets the delayWhileIdle property (default value is false). +
+
+

+E

+
+
ERROR_DEVICE_QUOTA_EXCEEDED - +Static variable in class com.google.android.gcm.server.Constants +
Too many messages sent by the sender to a specific device. +
ERROR_INVALID_REGISTRATION - +Static variable in class com.google.android.gcm.server.Constants +
Bad registration_id. +
ERROR_MESSAGE_TOO_BIG - +Static variable in class com.google.android.gcm.server.Constants +
The payload of the message is too big, see the limitations. +
ERROR_MISMATCH_SENDER_ID - +Static variable in class com.google.android.gcm.server.Constants +
The sender_id contained in the registration_id does not match the + sender_id used to register with the GCM servers. +
ERROR_MISSING_COLLAPSE_KEY - +Static variable in class com.google.android.gcm.server.Constants +
Collapse key is required. +
ERROR_MISSING_REGISTRATION - +Static variable in class com.google.android.gcm.server.Constants +
Missing registration_id. +
ERROR_NOT_REGISTERED - +Static variable in class com.google.android.gcm.server.Constants +
The user has uninstalled the application or turned off notifications. +
ERROR_QUOTA_EXCEEDED - +Static variable in class com.google.android.gcm.server.Constants +
Too many messages sent by the sender. +
ERROR_UNAVAILABLE - +Static variable in class com.google.android.gcm.server.Constants +
Used to indicate that a particular message could not be sent because + the GCM servers were not available. +
+
+

+G

+
+
GCM_SEND_ENDPOINT - +Static variable in class com.google.android.gcm.server.Constants +
Endpoint for sending messages. +
getCanonicalIds() - +Method in class com.google.android.gcm.server.MulticastResult +
Gets the number of successful messages that also returned a canonical + registration id. +
getCanonicalRegistrationId() - +Method in class com.google.android.gcm.server.Result +
Gets the canonical registration id, if any. +
getCollapseKey() - +Method in class com.google.android.gcm.server.Message +
Gets the collapse key. +
getConnection(String) - +Method in class com.google.android.gcm.server.Sender +
Gets an HttpURLConnection given an URL. +
getData() - +Method in class com.google.android.gcm.server.Message +
Gets the payload data, which is immutable. +
getDescription() - +Method in exception com.google.android.gcm.server.InvalidRequestException +
Gets the error description. +
getErrorCodeName() - +Method in class com.google.android.gcm.server.Result +
Gets the error code, if any. +
getFailure() - +Method in class com.google.android.gcm.server.MulticastResult +
Gets the number of failed messages. +
getHttpStatusCode() - +Method in exception com.google.android.gcm.server.InvalidRequestException +
Gets the HTTP Status Code. +
getMessageId() - +Method in class com.google.android.gcm.server.Result +
Gets the message id, if any. +
getMulticastId() - +Method in class com.google.android.gcm.server.MulticastResult +
Gets the multicast id. +
getResults() - +Method in class com.google.android.gcm.server.MulticastResult +
Gets the results of each individual message, which is immutable. +
getRetryMulticastIds() - +Method in class com.google.android.gcm.server.MulticastResult +
Gets additional ids if more than one multicast message was sent. +
getString(InputStream) - +Static method in class com.google.android.gcm.server.Sender +
Convenience method to convert an InputStream to a String. +
getSuccess() - +Method in class com.google.android.gcm.server.MulticastResult +
Gets the number of successful messages. +
getTimeToLive() - +Method in class com.google.android.gcm.server.Message +
Gets the time to live (in seconds). +
getTotal() - +Method in class com.google.android.gcm.server.MulticastResult +
Gets the total number of messages sent, regardless of the status. +
+
+

+I

+
+
InvalidRequestException - Exception in com.google.android.gcm.server
Exception thrown when GCM returned an error due to an invalid request.
InvalidRequestException(int) - +Constructor for exception com.google.android.gcm.server.InvalidRequestException +
  +
InvalidRequestException(int, String) - +Constructor for exception com.google.android.gcm.server.InvalidRequestException +
  +
isDelayWhileIdle() - +Method in class com.google.android.gcm.server.Message +
Gets the delayWhileIdle flag. +
+
+

+J

+
+
JSON_CANONICAL_IDS - +Static variable in class com.google.android.gcm.server.Constants +
JSON-only field representing the number of messages with a canonical + registration id. +
JSON_ERROR - +Static variable in class com.google.android.gcm.server.Constants +
JSON-only field representing the error field of an individual request. +
JSON_FAILURE - +Static variable in class com.google.android.gcm.server.Constants +
JSON-only field representing the number of failed messages. +
JSON_MESSAGE_ID - +Static variable in class com.google.android.gcm.server.Constants +
JSON-only field sent by GCM when a message was successfully sent. +
JSON_MULTICAST_ID - +Static variable in class com.google.android.gcm.server.Constants +
JSON-only field representing the id of the multicast request. +
JSON_PAYLOAD - +Static variable in class com.google.android.gcm.server.Constants +
JSON-only field representing the payload data. +
JSON_REGISTRATION_IDS - +Static variable in class com.google.android.gcm.server.Constants +
JSON-only field representing the registration ids. +
JSON_RESULTS - +Static variable in class com.google.android.gcm.server.Constants +
JSON-only field representing the result of each individual request. +
JSON_SUCCESS - +Static variable in class com.google.android.gcm.server.Constants +
JSON-only field representing the number of successful messages. +
+
+

+L

+
+
logger - +Variable in class com.google.android.gcm.server.Sender +
  +
+
+

+M

+
+
MAX_BACKOFF_DELAY - +Static variable in class com.google.android.gcm.server.Sender +
Maximum delay before a retry. +
Message - Class in com.google.android.gcm.server
GCM message.
Message.Builder - Class in com.google.android.gcm.server
 
Message.Builder() - +Constructor for class com.google.android.gcm.server.Message.Builder +
  +
MulticastResult - Class in com.google.android.gcm.server
Result of a GCM multicast message request .
+
+

+N

+
+
newBody(String, String) - +Static method in class com.google.android.gcm.server.Sender +
Creates a StringBuilder to be used as the body of an HTTP POST. +
newKeyValues(String, String) - +Static method in class com.google.android.gcm.server.Sender +
Creates a map with just one key-value pair. +
+
+

+P

+
+
PARAM_COLLAPSE_KEY - +Static variable in class com.google.android.gcm.server.Constants +
HTTP parameter for collapse key. +
PARAM_DELAY_WHILE_IDLE - +Static variable in class com.google.android.gcm.server.Constants +
HTTP parameter for delaying the message delivery if the device is idle. +
PARAM_PAYLOAD_PREFIX - +Static variable in class com.google.android.gcm.server.Constants +
Prefix to HTTP parameter used to pass key-values in the message payload. +
PARAM_REGISTRATION_ID - +Static variable in class com.google.android.gcm.server.Constants +
HTTP parameter for registration id. +
PARAM_TIME_TO_LIVE - +Static variable in class com.google.android.gcm.server.Constants +
Prefix to HTTP parameter used to set the message time-to-live. +
post(String, String) - +Method in class com.google.android.gcm.server.Sender +
Make an HTTP post to a given URL. +
post(String, String, String) - +Method in class com.google.android.gcm.server.Sender +
  +
+
+

+R

+
+
random - +Variable in class com.google.android.gcm.server.Sender +
  +
Result - Class in com.google.android.gcm.server
Result of a GCM message request that returned HTTP status code 200.
+
+

+S

+
+
send(Message, String, int) - +Method in class com.google.android.gcm.server.Sender +
Sends a message to one device, retrying in case of unavailability. +
send(Message, List<String>, int) - +Method in class com.google.android.gcm.server.Sender +
Sends a message to many devices, retrying in case of unavailability. +
Sender - Class in com.google.android.gcm.server
Helper class to send messages to the GCM service using an API Key.
Sender(String) - +Constructor for class com.google.android.gcm.server.Sender +
Default constructor. +
sendNoRetry(Message, String) - +Method in class com.google.android.gcm.server.Sender +
Sends a message without retrying in case of service unavailability. +
sendNoRetry(Message, List<String>) - +Method in class com.google.android.gcm.server.Sender +
Sends a message without retrying in case of service unavailability. +
+
+

+T

+
+
timeToLive(int) - +Method in class com.google.android.gcm.server.Message.Builder +
Sets the time to live, in seconds. +
TOKEN_CANONICAL_REG_ID - +Static variable in class com.google.android.gcm.server.Constants +
Token returned by GCM when the requested registration id has a canonical + value. +
TOKEN_ERROR - +Static variable in class com.google.android.gcm.server.Constants +
Token returned by GCM when there was an error sending a message. +
TOKEN_MESSAGE_ID - +Static variable in class com.google.android.gcm.server.Constants +
Token returned by GCM when a message was successfully sent. +
toString() - +Method in class com.google.android.gcm.server.Message +
  +
toString() - +Method in class com.google.android.gcm.server.MulticastResult +
  +
toString() - +Method in class com.google.android.gcm.server.Result +
  +
+
+

+U

+
+
UTF8 - +Static variable in class com.google.android.gcm.server.Sender +
  +
+
+A B C D E G I J L M N P R S T U + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + diff --git a/docs/html/guide/google/gcm/server-javadoc/index.html b/docs/html/guide/google/gcm/server-javadoc/index.html new file mode 100644 index 0000000000000..efcce9ebe50b5 --- /dev/null +++ b/docs/html/guide/google/gcm/server-javadoc/index.html @@ -0,0 +1,36 @@ + + + + + + +Generated Documentation (Untitled) + + + + + + + + +<H2> +Frame Alert</H2> + +<P> +This document is designed to be viewed using the frames feature. If you see this message, you are using a non-frame-capable web client. +<BR> +Link to<A HREF="com/google/android/gcm/server/package-summary.html">Non-frame version.</A> + + + diff --git a/docs/html/guide/google/gcm/server-javadoc/overview-tree.html b/docs/html/guide/google/gcm/server-javadoc/overview-tree.html new file mode 100644 index 0000000000000..034838be79d71 --- /dev/null +++ b/docs/html/guide/google/gcm/server-javadoc/overview-tree.html @@ -0,0 +1,158 @@ + + + + + + +Class Hierarchy + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+
+

+Hierarchy For All Packages

+
+
+
Package Hierarchies:
com.google.android.gcm.server
+
+

+Class Hierarchy +

+ +
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + diff --git a/docs/html/guide/google/gcm/server-javadoc/package-list b/docs/html/guide/google/gcm/server-javadoc/package-list new file mode 100644 index 0000000000000..5955cc0827f5d --- /dev/null +++ b/docs/html/guide/google/gcm/server-javadoc/package-list @@ -0,0 +1 @@ +com.google.android.gcm.server diff --git a/docs/html/guide/google/gcm/server-javadoc/resources/inherit.gif b/docs/html/guide/google/gcm/server-javadoc/resources/inherit.gif new file mode 100644 index 0000000000000..c814867a13deb Binary files /dev/null and b/docs/html/guide/google/gcm/server-javadoc/resources/inherit.gif differ diff --git a/docs/html/guide/google/gcm/server-javadoc/serialized-form.html b/docs/html/guide/google/gcm/server-javadoc/serialized-form.html new file mode 100644 index 0000000000000..86cd61a55fe31 --- /dev/null +++ b/docs/html/guide/google/gcm/server-javadoc/serialized-form.html @@ -0,0 +1,355 @@ + + + + + + +Serialized Form + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+
+

+Serialized Form

+
+
+ + + + + +
+Package com.google.android.gcm.server
+ +

+ + + + + +
+Class com.google.android.gcm.server.InvalidRequestException extends java.io.IOException implements Serializable
+ +

+ + + + + +
+Serialized Fields
+ +

+status

+
+int status
+
+
+
+
+
+

+description

+
+java.lang.String description
+
+
+
+
+ +

+ + + + + +
+Class com.google.android.gcm.server.Message extends java.lang.Object implements Serializable
+ +

+ + + + + +
+Serialized Fields
+ +

+collapseKey

+
+java.lang.String collapseKey
+
+
+
+
+
+

+delayWhileIdle

+
+java.lang.Boolean delayWhileIdle
+
+
+
+
+
+

+timeToLive

+
+java.lang.Integer timeToLive
+
+
+
+
+
+

+data

+
+java.util.Map<K,V> data
+
+
+
+
+ +

+ + + + + +
+Class com.google.android.gcm.server.MulticastResult extends java.lang.Object implements Serializable
+ +

+ + + + + +
+Serialized Fields
+ +

+success

+
+int success
+
+
+
+
+
+

+failure

+
+int failure
+
+
+
+
+
+

+canonicalIds

+
+int canonicalIds
+
+
+
+
+
+

+multicastId

+
+long multicastId
+
+
+
+
+
+

+results

+
+java.util.List<E> results
+
+
+
+
+
+

+retryMulticastIds

+
+java.util.List<E> retryMulticastIds
+
+
+
+
+ +

+ + + + + +
+Class com.google.android.gcm.server.Result extends java.lang.Object implements Serializable
+ +

+ + + + + +
+Serialized Fields
+ +

+messageId

+
+java.lang.String messageId
+
+
+
+
+
+

+canonicalRegistrationId

+
+java.lang.String canonicalRegistrationId
+
+
+
+
+
+

+errorCode

+
+java.lang.String errorCode
+
+
+
+
+ +

+


+ + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + diff --git a/docs/html/guide/google/gcm/server-javadoc/stylesheet.css b/docs/html/guide/google/gcm/server-javadoc/stylesheet.css new file mode 100644 index 0000000000000..6ea9e5161615f --- /dev/null +++ b/docs/html/guide/google/gcm/server-javadoc/stylesheet.css @@ -0,0 +1,29 @@ +/* Javadoc style sheet */ + +/* Define colors, fonts and other style attributes here to override the defaults */ + +/* Page background color */ +body { background-color: #FFFFFF; color:#000000 } + +/* Headings */ +h1 { font-size: 145% } + +/* Table colors */ +.TableHeadingColor { background: #CCCCFF; color:#000000 } /* Dark mauve */ +.TableSubHeadingColor { background: #EEEEFF; color:#000000 } /* Light mauve */ +.TableRowColor { background: #FFFFFF; color:#000000 } /* White */ + +/* Font used in left-hand frame lists */ +.FrameTitleFont { font-size: 100%; font-family: Helvetica, Arial, sans-serif; color:#000000 } +.FrameHeadingFont { font-size: 90%; font-family: Helvetica, Arial, sans-serif; color:#000000 } +.FrameItemFont { font-size: 90%; font-family: Helvetica, Arial, sans-serif; color:#000000 } + +/* Navigation bar fonts and colors */ +.NavBarCell1 { background-color:#EEEEFF; color:#000000} /* Light mauve */ +.NavBarCell1Rev { background-color:#00008B; color:#FFFFFF} /* Dark Blue */ +.NavBarFont1 { font-family: Arial, Helvetica, sans-serif; color:#000000;color:#000000;} +.NavBarFont1Rev { font-family: Arial, Helvetica, sans-serif; color:#FFFFFF;color:#FFFFFF;} + +.NavBarCell2 { font-family: Arial, Helvetica, sans-serif; background-color:#FFFFFF; color:#000000} +.NavBarCell3 { font-family: Arial, Helvetica, sans-serif; background-color:#FFFFFF; color:#000000} + diff --git a/docs/html/guide/guide_toc.cs b/docs/html/guide/guide_toc.cs index af1ea6b4b9f19..91fa817d6b539 100644 --- a/docs/html/guide/guide_toc.cs +++ b/docs/html/guide/guide_toc.cs @@ -616,6 +616,29 @@
  • APK Expansion Files
  • + + diff --git a/docs/html/images/gcm/gcm-api-access.png b/docs/html/images/gcm/gcm-api-access.png new file mode 100644 index 0000000000000..5dfa4349f2f74 Binary files /dev/null and b/docs/html/images/gcm/gcm-api-access.png differ diff --git a/docs/html/images/gcm/gcm-api-key.png b/docs/html/images/gcm/gcm-api-key.png new file mode 100644 index 0000000000000..92834bf3f8f76 Binary files /dev/null and b/docs/html/images/gcm/gcm-api-key.png differ diff --git a/docs/html/images/gcm/gcm-avd-first-msg.png b/docs/html/images/gcm/gcm-avd-first-msg.png new file mode 100644 index 0000000000000..86296b5fb9cd3 Binary files /dev/null and b/docs/html/images/gcm/gcm-avd-first-msg.png differ diff --git a/docs/html/images/gcm/gcm-avd-home-auto-reg.png b/docs/html/images/gcm/gcm-avd-home-auto-reg.png new file mode 100644 index 0000000000000..986fc6320f5aa Binary files /dev/null and b/docs/html/images/gcm/gcm-avd-home-auto-reg.png differ diff --git a/docs/html/images/gcm/gcm-config-server-key.png b/docs/html/images/gcm/gcm-config-server-key.png new file mode 100644 index 0000000000000..90dd65d40cb53 Binary files /dev/null and b/docs/html/images/gcm/gcm-config-server-key.png differ diff --git a/docs/html/images/gcm/gcm-create-api-proj.png b/docs/html/images/gcm/gcm-create-api-proj.png new file mode 100644 index 0000000000000..6ef5cd23a75f7 Binary files /dev/null and b/docs/html/images/gcm/gcm-create-api-proj.png differ diff --git a/docs/html/images/gcm/gcm-demo-homepage-appengine.png b/docs/html/images/gcm/gcm-demo-homepage-appengine.png new file mode 100644 index 0000000000000..799d6d56a52fb Binary files /dev/null and b/docs/html/images/gcm/gcm-demo-homepage-appengine.png differ diff --git a/docs/html/images/gcm/gcm-demo-homepage.png b/docs/html/images/gcm/gcm-demo-homepage.png new file mode 100644 index 0000000000000..5f9748728d7a0 Binary files /dev/null and b/docs/html/images/gcm/gcm-demo-homepage.png differ diff --git a/docs/html/images/gcm/gcm-device-reg.png b/docs/html/images/gcm/gcm-device-reg.png new file mode 100644 index 0000000000000..643f12016e56c Binary files /dev/null and b/docs/html/images/gcm/gcm-device-reg.png differ diff --git a/docs/html/images/gcm/gcm-logo.png b/docs/html/images/gcm/gcm-logo.png new file mode 100644 index 0000000000000..14b92ada34f63 Binary files /dev/null and b/docs/html/images/gcm/gcm-logo.png differ diff --git a/docs/html/images/gcm/gcm-sent-server.png b/docs/html/images/gcm/gcm-sent-server.png new file mode 100644 index 0000000000000..6d19b0b273cce Binary files /dev/null and b/docs/html/images/gcm/gcm-sent-server.png differ