| Field | Description |
|---|---|
registration_ids |
A 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_key |
An 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. |
data |
A JSON object whose fields represents the key-value pairs of the message's payload data. If present, the payload data it will be
included in the Intent as application data, with the key being the extra's name. For instance, "data":{"score":"3x1"} would result in an intent extra named score whose value is the string 3x1.
There is no limit on the number of key/value pairs, though there is a
limit on the total size of the message (4kb). Note that the values must be enclosed by strings.
If you want to include objects or other non-string data types (such as
integers or booleans), you have to do the conversion to string yourself.
Also note that the key cannot be a reserved word (from or any word starting with google.). Optional. |
delay_while_idle |
If 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_live |
How 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. |
2012年8月25日 星期六
For JSON, it must contain a string representing a JSON object with the following fields:
string representing a JSON object with the following fields:
The following table specifies the API Level supported by each version of the Android platform.
Migrating Your Apps
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.
從GCM接收到響應後,所獲得的註冊ID必須被發送到應用程序服務器。在這樣做時,應用程序應該表明它已被發送一個GCM註冊ID,這樣服務器可以區分它從現有的C2DM註冊。
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:
- The request should be sent to a new endpoint:
https://android.googleapis.com/gcm/send. - The Authorization header of the request should contain the API key generated during sign up. This key replaces the deprecated ClientLogin Auth token.
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.
2012年8月24日 星期五
append()
append()
http://blog.xuite.net/x_3kkk/java/11386460-%E5%AD%97%E4%B8%B2%E7%9A%84%E6%96%B0%E5%A2%9E%E8%88%87%E6%8F%92%E5%85%A5+%28+append+%2F+insert+%29
http://blog.xuite.net/x_3kkk/java/11386460-%E5%AD%97%E4%B8%B2%E7%9A%84%E6%96%B0%E5%A2%9E%E8%88%87%E6%8F%92%E5%85%A5+%28+append+%2F+insert+%29
2012年8月17日 星期五
2012年8月15日 星期三
compile kernel error
out/host/linux-x86/obj/EXECUTABLES/test-librsloader_intermediates/test-librsloader] Error 1
1. Install gcc4.4
apt-get gcc-4.4 and gcc-4.4-multilib and do
2. Use this command to build
make CC=gcc-4.4 CXX=g++-4.4
https://groups.google.com/forum/#!msg/android-building/GhtCJSBDwUw/WkKtUiNB_moJ[1-25]
out/host/linux-x86/obj/EXECUTABLES/aapt_intermediates/aapt
https://groups.google.com/forum/#!msg/android-building/GhtCJSBDwUw/WkKtUiNB_moJ[1-25]
out/host/linux-x86/obj/EXECUTABLES/aapt_intermediates/aapt
2012年8月8日 星期三
Java note
@link:
/**
*亂說一同
* @link package.class #getValue
* @param
* @see #getValue
*/ @link是一個連接標記,在doc裡會多增加一個See Also(默認的類是自己) #member label就是把@see獲取到。你可以試一下就明白了
http://topic.csdn.net/t/20031222/14/2589902.html
http://www.thebuzzmedia.com/supported-values-for-suppresswarnings/
public class GCMIntentService extends GCMBaseIntentService {
// @SuppressWarnings("hiding")
private static final String TAG = "GCMIntentService";
public GCMIntentService() {
super("SENDER_ID");
}
/**
*亂說一同
* @link package.class #getValue
* @param
* @see #getValue
*/ @link是一個連接標記,在doc裡會多增加一個See Also(默認的類是自己) #member label就是把@see獲取到。你可以試一下就明白了
http://topic.csdn.net/t/20031222/14/2589902.html
@SuppressWarnings
hiding to suppress warnings relative to locals that hide variable
java.lang.ObjectIntentService
com.google.android.gcm.GCMBaseIntentService
| Field Summary | |
|---|---|
static java.lang.String | TAG |
protected GCMBaseIntentService(String senderId) {
// name is used as base name for threads, etc.
super("GCMIntentService-" + senderId + "-" + (++sCounter));
mSenderId = senderId;
}
| Constructor Summary | |
|---|---|
protected | GCMBaseIntentService()
Constructor that does not set a sender id, useful when the sender id is context-specific. |
protected | GCMBaseIntentService(java.lang.String... senderIds)
Constructor used when the sender id(s) is fixed. |
訂閱:
文章 (Atom)