Skip to content

Commit 2a17520

Browse files
labtopiaAndroid (Google) Code Review
authored andcommitted
Merge "Doc update: GCM doc cleanup." into jb-dev
2 parents 9075248 + 7cd6dcd commit 2a17520

File tree

4 files changed

+34
-14
lines changed

4 files changed

+34
-14
lines changed

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

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,11 @@ page.title=Migration
1717

1818
<ol>
1919
<li><a href="#history">Historical Overview</a></li>
20-
<li><a href="#diffs">How is GCM Different from C2DM?</a></li>
20+
<li><a href="#diffs">How is GCM Different from C2DM?</a>
21+
<ol>
22+
<li><a href="#interop">Relationship between C2DM and GCM</a></li>
23+
</ol>
24+
</li>
2125
<li><a href="#migrating">Migrating Your Apps</a>
2226
<ol>
2327
<li><a href="#client">Client changes</a></li>
@@ -72,6 +76,14 @@ page.title=Migration
7276
<dd>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 <a href="adv.html#canonical">Advanced Topics</a>.</dd>
7377
</dl>
7478
<p>GCM also provides helper libraries (<a href="{@docRoot}guide/google/gcm/client-javadoc/index.html">client</a> and <a href="{@docRoot}guide/google/gcm/server-javadoc/index.html">server</a>) to make writing your code easier.</p>
79+
80+
<h3 id="interop">Relationship between C2DM and GCM</h3>
81+
82+
<p>C2DM and GCM are not interoperable. For example, you cannot post notifications from GCM to C2DM registration IDs, nor can you use C2DM registration IDs as GCM registration IDs. From your server-side application, you must keep keep track of whether a registration ID is from C2DM or GCM and use the proper endpoint. </p>
83+
84+
<p>As you transition from C2DM to GCM, your server needs to be aware of whether a given registration ID
85+
contains an old C2DM sender or a new GCM project ID. This is the approach we recommend: have the new app version (the one that uses GCM) send a bit along with the registration ID. This bit tells your server that this registration ID is for GCM. If you don't get the extra bit, you mark the registration ID as C2DM. Once no more valid registration IDs are marked as C2DM, you can complete the migration.</p>
86+
7587
<h2 id="migrating">Migrating Your Apps</h2>
7688
<p>This section describes how to move existing C2DM apps to GCM.</p>
7789
<h3 id="client">Client changes</h3>

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,11 @@ page.title=GCM Demo Application
7474
<li> From the SDK Manager, install <strong>Extras &gt; Google Cloud Messaging for Android Library</strong>.
7575

7676

77-
<p>This creates a <code>gcm</code> directory under <code><em>YOUR_SDK_ROOT</em>/extras/google/</code> containing these subdirectories: <code>gcm-client</code>, <code>gcm-demo-appengine</code>, <code>gcm-demo-client</code>, <code>gcm-demo-server</code>, and <code>gcm-server</code>.</p>
77+
<p>This creates a <code>gcm</code> directory under <code><em>YOUR_SDK_ROOT</em>/extras/google/</code> containing these subdirectories: <code>gcm-client</code>, <code>gcm-server</code>, <code>samples/gcm-demo-client</code>, <code>samples/gcm-demo-server</code>, and <code>samples/gcm-demo-appengine</code>.</p>
7878
</li>
7979

80-
<li>In a text editor, edit the <code>gcm-demo-server/WebContent/WEB-INF/classes/api.key</code> and replace the existing text with the API key obtained above.</li>
81-
<li>In a shell window, go to the <code>gcm-demo-server</code> directory.</li>
80+
<li>In a text editor, edit the <code>samples/gcm-demo-server/WebContent/WEB-INF/classes/api.key</code> and replace the existing text with the API key obtained above.</li>
81+
<li>In a shell window, go to the <code>samples/gcm-demo-server</code> directory.</li>
8282
<li>Generate the server's WAR file by running <code>ant war</code>:</li>
8383

8484
<pre class="prettyprint">$ ant war
@@ -112,13 +112,13 @@ Total time: 0 seconds
112112
<p>To set up the server using a standard App Engine for Java:</p>
113113
<ol>
114114
<li> From the SDK Manager, install <strong>Extras &gt; Google Cloud Messaging for Android Library</strong>.
115-
<p>This creates a <code>gcm</code> directory under <code><em>YOUR_SDK_ROOT</em>/extras/google/</code> containing these subdirectories: <code>gcm-client</code>, <code>gcm-demo-appengine</code>, <code>gcm-demo-client</code>, <code>gcm-demo-server</code>, and <code>gcm-server</code>.</p>
115+
<p>This creates a <code>gcm</code> directory under <code><em>YOUR_SDK_ROOT</em>/extras/google/</code> containing these subdirectories: <code>gcm-client</code>, <code>gcm-server</code>, <code>samples/gcm-demo-client</code>, <code>samples/gcm-demo-server</code>, and <code>samples/gcm-demo-appengine</code>.</p>
116116
</li>
117-
<li>In a text editor, edit the <code>gcm-demo-appengine/src/com/google/android/gcm/demo/server/ApiKeyInitializer.java</code> and replace the existing text with the API key obtained above.
117+
<li>In a text editor, edit <code>samples/gcm-demo-appengine/src/com/google/android/gcm/demo/server/ApiKeyInitializer.java</code> and replace the existing text with the API key obtained above.
118118
<p class="note"><strong>Note:</strong> 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 <code>Datastore Viewer</code> to change it later.</p>
119119

120120
</li>
121-
<li>In a shell window, go to the <code>gcm-api-server</code> directory.</li>
121+
<li>In a shell window, go to the <code>samples/gcm-demo-appengine</code> directory.</li>
122122
<li>Start the development App Engine server by <code>ant runserver</code>, using the <code>-Dsdk.dir</code> to indicate the location of the App Engine SDK and <code>-Dserver.host</code> to set your server's hostname or IP address:</li>
123123

124124
<pre class="prettyprint">
@@ -163,9 +163,9 @@ runserver:
163163
<p>To set up the device:</p>
164164
<ol>
165165
<li> From the SDK Manager, install <strong>Extras &gt; Google Cloud Messaging for Android Library</strong>.
166-
<p>This creates a <code>gcm</code> directory under <code><em>YOUR_SDK_ROOT</em>/extras/google</code> containing these subdirectories: <code>gcm-client</code>, <code>gcm-demo-appengine</code>, <code>gcm-demo-client</code>, <code>gcm-demo-server</code>, <code>gcm-server</code>, and <code>source.properties</code>.</p>
166+
<p>This creates a <code>gcm</code> directory under <code><em>YOUR_SDK_ROOT</em>/extras/google</code> containing these subdirectories: <code>gcm-client</code>, <code>gcm-server</code>, <code>samples/gcm-demo-client</code>, <code>samples/gcm-demo-server</code>, and <code>samples/gcm-demo-appengine</code>.</p>
167167
</li>
168-
<li>Using a text editor, open <code>gcm-demo-client/src/com/google/android/gcm/demo/app/CommonUtilities.java</code> and set the proper values for the <code>SENDER_ID</code> and <code>SERVER_URL</code> constants. For example:</li>
168+
<li>Using a text editor, open <code>samples/gcm-demo-client/src/com/google/android/gcm/demo/app/CommonUtilities.java</code> and set the proper values for the <code>SENDER_ID</code> and <code>SERVER_URL</code> constants. For example:</li>
169169

170170
<pre class="prettyprint pretty-java">
171171
static final String SERVER_URL = &quot;http://192.168.1.10:8080/gcm-demo&quot;;

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

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ page.title=GCM: Getting Started
8585
<p class="note"><strong>Note:</strong> If you need to rotate the key, click <strong>Generate new key</strong>. 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 <strong>Delete key</strong>.</p>
8686

8787
<h2 id="libs">Install the Helper Libraries</h2>
88-
<p>To perform the steps described in the following sections, you must first install the helper libraries (reference: <a href="{@docRoot}guide/google/gcm/client-javadoc/index.html">client</a> and <a href="{@docRoot}guide/google/gcm/server-javadoc/index.html">server</a>). From the SDK Manager, install <strong>Extras &gt; Google Cloud Messaging for Android Library</strong>. This creates a <code>gcm</code> directory under <code><em>YOUR_SDK_ROOT</em>/extras/google/</code> containing these subdirectories: <code>gcm-client</code>, <code>gcm-demo-appengine</code>, <code>gcm-demo-client</code>, <code>gcm-demo-server</code>, and <code>gcm-server</code>.</p>
88+
<p>To perform the steps described in the following sections, you must first install the helper libraries (reference: <a href="{@docRoot}guide/google/gcm/client-javadoc/index.html">client</a> and <a href="{@docRoot}guide/google/gcm/server-javadoc/index.html">server</a>). From the SDK Manager, install <strong>Extras &gt; Google Cloud Messaging for Android Library</strong>. This creates a <code>gcm</code> directory under <code><em>YOUR_SDK_ROOT</em>/extras/google/</code> containing these subdirectories: <code>gcm-client</code>, <code>gcm-server</code>, <code>samples/gcm-demo-client</code>, <code>samples/gcm-demo-server</code>, and <code>samples/gcm-demo-appengine</code>.</p>
8989
<h2 id="android-app">Writing the Android Application</h2>
9090
<p>This section describes the steps involved in writing an Android application that uses GCM.</p>
9191
<h4>Step 1: Copy the gcm.jar file into your application classpath</h4>
@@ -104,9 +104,16 @@ page.title=GCM: Getting Started
104104
<p> This permission must be called <code>my_app_package.permission.C2D_MESSAGE</code> (where <code>my_app_package</code> is the package name of your app as defined by the manifest tag), otherwise it will not work.</p>
105105
<p class="note"><strong>Note:</strong> This permission is not required if you are targeting your application to 4.1 or above (i.e., minSdkVersion 16)</p>
106106

107-
<li>Add the permission to receive GCM messages:</li>
107+
<li>Add the following permissions:</li>
108108

109-
<pre class="prettyprint pretty-xml">&lt;uses-permission android:name=&quot;com.google.android.c2dm.permission.RECEIVE&quot; /&gt;</pre>
109+
<pre class="prettyprint pretty-xml">&lt;!-- App receives GCM messages. --&gt;
110+
&lt;uses-permission android:name=&quot;com.google.android.c2dm.permission.RECEIVE&quot; /&gt;
111+
&lt;!-- GCM connects to Google Services. --&gt;
112+
&lt;uses-permission android:name=&quot;android.permission.INTERNET&quot; /&gt;
113+
&lt;!-- GCM requires a Google account. --&gt;
114+
&lt;uses-permission android:name=&quot;android.permission.GET_ACCOUNTS&quot; /&gt;
115+
&lt;!-- Keeps the processor from sleeping when a message is received. --&gt;
116+
&lt;uses-permission android:name=&quot;android.permission.WAKE_LOCK&quot; /&gt;</pre>
110117

111118
<li>Add the following broadcast receiver:</li>
112119

@@ -127,7 +134,7 @@ page.title=GCM: Getting Started
127134
<pre class="prettyprint pretty-xml">&lt;service android:name=&quot;.GCMIntentService&quot; /&gt;</pre>
128135

129136
</ol>
130-
<p> This intent service will be called by the <code>GCMBroadcastReceiver</code> (which is is provided by GCM library), as shown in the next step. It must be named <code>my_app_package.GCMIntentService</code>, unless you use a subclass of <code>GCMBroadcastReceiver</code> that overrides the method used to name the service.</p>
137+
<p>This intent service will be called by the <code>GCMBroadcastReceiver</code> (which is is provided by GCM library), as shown in the next step. It must be a subclass of <code>com.google.android.gcm.GCMBaseIntentService</code>, must contain a public constructor, and should be named <code>my_app_package.GCMIntentService</code> (unless you use a subclass of <code>GCMBroadcastReceiver</code> that overrides the method used to name the service).</p>
131138
<h4><br>
132139
Step 3: Write the my_app_package.GCMIntentService class</h4>
133140
<p>Next write the <code>my_app_package.GCMIntentService</code> class, overriding the following callback methods (which are called by <code>GCMBroadcastReceiver</code>):<br>

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ page.title=Google Cloud Messaging for Android
55
<p><img src="{@docRoot}images/gcm/gcm-logo.png" /></p>
66
<p>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.</p>
77

8-
<p>To learn more about GCM, read the following documents:</p>
8+
<p>To learn more about GCM, you can join the <a href="https://groups.google.com/forum/?fromgroups#!forum/android-gcm">android-gcm group</a> and read the following documents:</p>
99

1010
<dl>
1111
<dt><strong><a href="{@docRoot}guide/google/gcm/gs.html">Getting Started</a></strong></dt>
@@ -23,3 +23,4 @@ page.title=Google Cloud Messaging for Android
2323
<p>GCM also provides helper libraries for <a href="{@docRoot}guide/google/gcm/client-javadoc/index.html"><strong>client</strong></a> and <a href="{@docRoot}guide/google/gcm/server-javadoc/index.html"><strong>server</strong></a> development.</p>
2424

2525

26+

0 commit comments

Comments
 (0)