Skip to content

Commit 60c8f99

Browse files
committed
Doc update: GCM doc cleanup, continued.
Change-Id: Ia668bc6b80b5d53c9fa815db888e75d8efbbc772
1 parent 0f8e402 commit 60c8f99

40 files changed

+8464
-146
lines changed

docs/html/guide/google/gcm/adv.jd

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ page.title=GCM Advanced Topics
2727
<ol>
2828
<li><a href="#s2s">Send-to-sync messages</a></li>
2929
<li><a href="#payload">Messages with payload</a></li>
30+
<li><a href="#which">Which should I use?</a></li>
3031
</ol>
3132
</li>
3233
<li><a href="#ttl">Setting an Expiration Date for a Message</a> </li>
@@ -185,10 +186,22 @@ registerReceiver(mRetryReceiver, filter);
185186
<p>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 <code>NotRegistered</code> error, without any further action being required from the 3rd-party server (this scenario happens frequently while an application is being developed and tested).</p>
186187

187188
<h2 id="collapsible">Send-to-Sync vs. Messages with Payload</h2>
188-
<p>Every message sent in GCM, regardless of its other characteristics, is either a &quot;send-to-sync&quot; (collapsible) message or a &quot;message with payload&quot; (non-collapsible message).</p>
189+
190+
<p>Every message sent in GCM has the following characteristics:</p>
191+
<ul>
192+
<li>It has a payload limit of 4096 bytes.</li>
193+
<li>By default, it is stored by GCM for 4 weeks.</li>
194+
</ul>
195+
196+
<p>But despite these similarities, messages can behave very differently depending on their particular settings. One major distinction between messages is whether they are collapsed (where each new message replaces the preceding message) or not collapsed (where each individual message is delivered). Every message sent in GCM is either a &quot;send-to-sync&quot; (collapsible) message or a &quot;message with payload&quot; (non-collapsible message). These concepts are described in more detail in the following sections.</p>
197+
189198
<h3 id="s2s"><strong>Send-to-sync messages</strong></h3>
190-
<p>A send-to-sync (collapsible) message is typically a &quot;tickle&quot; 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 &quot;New mail&quot; 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 &quot;New mail&quot; message. One is sufficient. This is a case where you would use the GCM <code>collapse_key</code> parameter. A <em>collapse key</em> 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, &quot;New mail,&quot; &quot;Updates available,&quot; and so on</p>
191-
<p>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.</p>
199+
200+
<p>A send-to-sync (collapsible) message is often a &quot;tickle&quot; 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 &quot;New mail&quot; 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 &quot;New mail&quot; message. One is sufficient. Another example would be a sports application that updates users with the latest score. Only the most recent message is relevant, so it makes sense to have each new message replace the preceding message. </p>
201+
202+
<p>The email and sports applications are cases where you would probably use the GCM <code>collapse_key</code> parameter. A <em>collapse key</em> is an arbitrary string that is used to collapse a group of like messages when the device is offline, so that only the most recent message gets sent to the client. For example, &quot;New mail,&quot; &quot;Updates available,&quot; and so on</p>
203+
<p>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. If you exceed this number GCM will only keep 4 collapse keys, with no guarantees about which ones they will be.</p>
204+
192205
<h3 id="payload">Messages with payload</h3>
193206
<p>Unlike a send-to-sync message, every &quot;message with payload&quot; (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:</p>
194207

@@ -208,9 +221,10 @@ registerReceiver(mRetryReceiver, filter);
208221
<li><code>total_deleted</code>&mdash;The value is a string with the number of deleted messages.</li>
209222
</ul>
210223
<p>The application should respond by syncing with the server to recover the discarded messages. </p>
211-
<p class="note"><strong>Note:</strong> 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.
212-
213-
</p>
224+
225+
<h3 id="which">Which should I use?</h3>
226+
<p>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.</p>
227+
214228
<h2 dir="ltr" id="ttl">Setting an Expiration Date for a Message</h2>
215229
<p>The Time to Live (TTL) feature lets the sender specify the maximum lifespan of a message using the <code>time_to_live</code> 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.</p>
216230
<p>Here are some possible uses for this feature:</p>

docs/html/guide/google/gcm/client-javadoc/allclasses-frame.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22
<!--NewPage-->
33
<HTML>
44
<HEAD>
5-
<!-- Generated by javadoc (build 1.6.0_20) on Thu Jun 21 12:06:25 PDT 2012 -->
5+
<!-- Generated by javadoc (build 1.6.0_26) on Mon Jul 16 14:13:37 PDT 2012 -->
66
<TITLE>
77
All Classes
88
</TITLE>
99

10-
<META NAME="date" CONTENT="2012-06-21">
10+
<META NAME="date" CONTENT="2012-07-16">
1111

12-
<LINK REL ="stylesheet" TYPE="text/css" HREF="stylesheet.css" TITLE="Style">
12+
<LINK REL ="stylesheet" TYPE="text/css" HREF="default.css" TITLE="Style">
1313

1414

1515
</HEAD>

docs/html/guide/google/gcm/client-javadoc/allclasses-noframe.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22
<!--NewPage-->
33
<HTML>
44
<HEAD>
5-
<!-- Generated by javadoc (build 1.6.0_20) on Thu Jun 21 12:06:25 PDT 2012 -->
5+
<!-- Generated by javadoc (build 1.6.0_26) on Mon Jul 16 14:13:37 PDT 2012 -->
66
<TITLE>
77
All Classes
88
</TITLE>
99

10-
<META NAME="date" CONTENT="2012-06-21">
10+
<META NAME="date" CONTENT="2012-07-16">
1111

12-
<LINK REL ="stylesheet" TYPE="text/css" HREF="stylesheet.css" TITLE="Style">
12+
<LINK REL ="stylesheet" TYPE="text/css" HREF="default.css" TITLE="Style">
1313

1414

1515
</HEAD>

docs/html/guide/google/gcm/client-javadoc/com/google/android/gcm/GCMBaseIntentService.html

Lines changed: 61 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22
<!--NewPage-->
33
<HTML>
44
<HEAD>
5-
<!-- Generated by javadoc (build 1.6.0_20) on Thu Jun 21 12:06:25 PDT 2012 -->
5+
<!-- Generated by javadoc (build 1.6.0_26) on Mon Jul 16 14:13:36 PDT 2012 -->
66
<TITLE>
77
GCMBaseIntentService
88
</TITLE>
99

10-
<META NAME="date" CONTENT="2012-06-21">
10+
<META NAME="date" CONTENT="2012-07-16">
1111

12-
<LINK REL ="stylesheet" TYPE="text/css" HREF="../../../../stylesheet.css" TITLE="Style">
12+
<LINK REL ="stylesheet" TYPE="text/css" HREF="../../../../default.css" TITLE="Style">
1313

1414
<SCRIPT type="text/javascript">
1515
function windowTitle()
@@ -107,6 +107,8 @@ <H2>
107107
hence should run in a limited amount of time. If they execute long
108108
operations, they should spawn new threads, otherwise the worker thread will
109109
be blocked.
110+
<p>
111+
Subclasses must provide a public no-arg constructor.
110112
<P>
111113

112114
<P>
@@ -142,11 +144,19 @@ <H2>
142144
<TR BGCOLOR="white" CLASS="TableRowColor">
143145
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
144146
<CODE>protected </CODE></FONT></TD>
145-
<TD><CODE><B><A HREF="../../../../com/google/android/gcm/GCMBaseIntentService.html#GCMBaseIntentService(java.lang.String)">GCMBaseIntentService</A></B>(java.lang.String&nbsp;senderId)</CODE>
147+
<TD><CODE><B><A HREF="../../../../com/google/android/gcm/GCMBaseIntentService.html#GCMBaseIntentService()">GCMBaseIntentService</A></B>()</CODE>
148+
149+
<BR>
150+
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Constructor that does not set a sender id, useful when the sender id
151+
is context-specific.</TD>
152+
</TR>
153+
<TR BGCOLOR="white" CLASS="TableRowColor">
154+
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
155+
<CODE>protected </CODE></FONT></TD>
156+
<TD><CODE><B><A HREF="../../../../com/google/android/gcm/GCMBaseIntentService.html#GCMBaseIntentService(java.lang.String...)">GCMBaseIntentService</A></B>(java.lang.String...&nbsp;senderIds)</CODE>
146157

147158
<BR>
148-
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Subclasses must create a public no-arg constructor and pass the
149-
sender id to be used for registration.</TD>
159+
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Constructor used when the sender id(s) is fixed.</TD>
150160
</TR>
151161
</TABLE>
152162
&nbsp;
@@ -160,6 +170,14 @@ <H2>
160170
</TR>
161171
<TR BGCOLOR="white" CLASS="TableRowColor">
162172
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
173+
<CODE>protected &nbsp;java.lang.String[]</CODE></FONT></TD>
174+
<TD><CODE><B><A HREF="../../../../com/google/android/gcm/GCMBaseIntentService.html#getSenderIds(Context)">getSenderIds</A></B>(Context&nbsp;context)</CODE>
175+
176+
<BR>
177+
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Gets the sender ids.</TD>
178+
</TR>
179+
<TR BGCOLOR="white" CLASS="TableRowColor">
180+
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
163181
<CODE>protected &nbsp;void</CODE></FONT></TD>
164182
<TD><CODE><B><A HREF="../../../../com/google/android/gcm/GCMBaseIntentService.html#onDeletedMessages(Context, int)">onDeletedMessages</A></B>(Context&nbsp;context,
165183
int&nbsp;total)</CODE>
@@ -263,13 +281,28 @@ <H2>
263281
</TR>
264282
</TABLE>
265283

266-
<A NAME="GCMBaseIntentService(java.lang.String)"><!-- --></A><H3>
284+
<A NAME="GCMBaseIntentService()"><!-- --></A><H3>
285+
GCMBaseIntentService</H3>
286+
<PRE>
287+
protected <B>GCMBaseIntentService</B>()</PRE>
288+
<DL>
289+
<DD>Constructor that does not set a sender id, useful when the sender id
290+
is context-specific.
291+
<p>
292+
When using this constructor, the subclass <strong>must</strong>
293+
override <A HREF="../../../../com/google/android/gcm/GCMBaseIntentService.html#getSenderIds(Context)"><CODE>getSenderIds(Context)</CODE></A>, otherwise methods such as
294+
<A HREF="../../../../com/google/android/gcm/GCMBaseIntentService.html#onHandleIntent(Intent)"><CODE>onHandleIntent(Intent)</CODE></A> will throw an
295+
<CODE>IllegalStateException</CODE> on runtime.
296+
<P>
297+
</DL>
298+
<HR>
299+
300+
<A NAME="GCMBaseIntentService(java.lang.String...)"><!-- --></A><H3>
267301
GCMBaseIntentService</H3>
268302
<PRE>
269-
protected <B>GCMBaseIntentService</B>(java.lang.String&nbsp;senderId)</PRE>
303+
protected <B>GCMBaseIntentService</B>(java.lang.String...&nbsp;senderIds)</PRE>
270304
<DL>
271-
<DD>Subclasses must create a public no-arg constructor and pass the
272-
sender id to be used for registration.
305+
<DD>Constructor used when the sender id(s) is fixed.
273306
<P>
274307
</DL>
275308

@@ -283,6 +316,24 @@ <H2>
283316
</TR>
284317
</TABLE>
285318

319+
<A NAME="getSenderIds(Context)"><!-- --></A><H3>
320+
getSenderIds</H3>
321+
<PRE>
322+
protected java.lang.String[] <B>getSenderIds</B>(Context&nbsp;context)</PRE>
323+
<DL>
324+
<DD>Gets the sender ids.
325+
326+
<p>By default, it returns the sender ids passed in the constructor, but
327+
it could be overridden to provide a dynamic sender id.
328+
<P>
329+
<DD><DL>
330+
331+
<DT><B>Throws:</B>
332+
<DD><CODE>java.lang.IllegalStateException</CODE> - if sender id was not set on constructor.</DL>
333+
</DD>
334+
</DL>
335+
<HR>
336+
286337
<A NAME="onMessage(Context, Intent)"><!-- --></A><H3>
287338
onMessage</H3>
288339
<PRE>

docs/html/guide/google/gcm/client-javadoc/com/google/android/gcm/GCMBroadcastReceiver.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22
<!--NewPage-->
33
<HTML>
44
<HEAD>
5-
<!-- Generated by javadoc (build 1.6.0_20) on Thu Jun 21 12:06:25 PDT 2012 -->
5+
<!-- Generated by javadoc (build 1.6.0_26) on Mon Jul 16 14:13:36 PDT 2012 -->
66
<TITLE>
77
GCMBroadcastReceiver
88
</TITLE>
99

10-
<META NAME="date" CONTENT="2012-06-21">
10+
<META NAME="date" CONTENT="2012-07-16">
1111

12-
<LINK REL ="stylesheet" TYPE="text/css" HREF="../../../../stylesheet.css" TITLE="Style">
12+
<LINK REL ="stylesheet" TYPE="text/css" HREF="../../../../default.css" TITLE="Style">
1313

1414
<SCRIPT type="text/javascript">
1515
function windowTitle()

docs/html/guide/google/gcm/client-javadoc/com/google/android/gcm/GCMConstants.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22
<!--NewPage-->
33
<HTML>
44
<HEAD>
5-
<!-- Generated by javadoc (build 1.6.0_20) on Thu Jun 21 12:06:25 PDT 2012 -->
5+
<!-- Generated by javadoc (build 1.6.0_26) on Mon Jul 16 14:13:36 PDT 2012 -->
66
<TITLE>
77
GCMConstants
88
</TITLE>
99

10-
<META NAME="date" CONTENT="2012-06-21">
10+
<META NAME="date" CONTENT="2012-07-16">
1111

12-
<LINK REL ="stylesheet" TYPE="text/css" HREF="../../../../stylesheet.css" TITLE="Style">
12+
<LINK REL ="stylesheet" TYPE="text/css" HREF="../../../../default.css" TITLE="Style">
1313

1414
<SCRIPT type="text/javascript">
1515
function windowTitle()

0 commit comments

Comments
 (0)