OLD | NEW |
1 <meta name="doc-family" content="apps"> | 1 <meta name="doc-family" content="apps"> |
2 <h1 id="gcm">Google Cloud Messaging</h1> | 2 <h1 id="gcm">Google Cloud Messaging</h1> |
3 | 3 |
4 <p>Google Cloud Messaging (GCM) is a service for both Android-powered device and | 4 <p>Google Cloud Messaging (GCM) is a service for both Android-powered device and |
5 Chrome instances to send and receive message data from servers. <a href="gcm.htm
l">GCM Chrome | 5 Chrome instances to send and receive message data from servers. <a href="gcm">GC
M Chrome |
6 API</a> allows the Chrome apps or extensions to access the GCM | 6 API</a> allows the Chrome apps or extensions to access the GCM |
7 service for the signed-in Chrome users. The service works even if an app or | 7 service for the signed-in Chrome users. The service works even if an app or |
8 extension isn't currently running. For example, calendar updates could be pushed | 8 extension isn't currently running. For example, calendar updates could be pushed |
9 to users even when their calendar app isn't open. </p> | 9 to users even when their calendar app isn't open. </p> |
10 | 10 |
11 <p>To use both API and service, you must agree to the <a href="https://developer
s.google.com/terms/">Google APIs Terms of | 11 <p>To use both API and service, you must agree to the <a href="https://developer
s.google.com/terms/">Google APIs Terms of |
12 Service</a> and <a href="https://developers.google.com/cloud/terms/">Google Clou
d Platform Terms | 12 Service</a> and <a href="https://developers.google.com/cloud/terms/">Google Clou
d Platform Terms |
13 of Service</a>.</p> | 13 of Service</a>.</p> |
14 | 14 |
15 <p>This document describes how to set up and use GCM. For additional information | 15 <p>This document describes how to set up and use GCM. For additional information |
16 see the reference documentation for the <a href="gcm.html">GCM Chrome API</a> an
d | 16 see the reference documentation for the <a href="gcm">GCM Chrome API</a> and |
17 the <a href="http://developer.android.com/google/gcm/index.html">GCM Service</a>
. To get | 17 the <a href="http://developer.android.com/google/gcm/index.html">GCM Service</a>
. To get |
18 help with GCM or to give us feedback, please see | 18 help with GCM or to give us feedback, please see |
19 <a href="#feedback">Feedback</a>.</p> | 19 <a href="#feedback">Feedback</a>.</p> |
20 | 20 |
21 <p>Please note that GCM Chrome API is experimental. It is only available to Chro
me | 21 <p>Please note that GCM Chrome API is experimental. It is only available to Chro
me |
22 users on the dev channel.</p> | 22 users on the dev channel.</p> |
23 | 23 |
24 <p class="note"><strong>API Samples</strong>: Want to play with the code? Check
out the | 24 <p class="note"><strong>API Samples</strong>: Want to play with the code? Check
out the |
25 <a href="https://github.com/GoogleChrome/chrome-app-samples/tree/master/gcm-noti
fications">gcm-notifications</a> | 25 <a href="https://github.com/GoogleChrome/chrome-app-samples/tree/master/gcm-noti
fications">gcm-notifications</a> |
26 sample.</p> | 26 sample.</p> |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 <code>manifest.json</code>.</p> | 114 <code>manifest.json</code>.</p> |
115 | 115 |
116 <pre data-filename="manifest.json"><code> | 116 <pre data-filename="manifest.json"><code> |
117 "permissions": [ | 117 "permissions": [ |
118 "gcm", "storage", ... | 118 "gcm", "storage", ... |
119 ] | 119 ] |
120 </code></pre> | 120 </code></pre> |
121 | 121 |
122 <p>Please note that the <code>storage</code> permission is also provided here be
cause the | 122 <p>Please note that the <code>storage</code> permission is also provided here be
cause the |
123 sample codes below needs to persist some data via the | 123 sample codes below needs to persist some data via the |
124 <a href="storage.html">chrome.storage</a> API.</p> | 124 <a href="storage">chrome.storage</a> API.</p> |
125 | 125 |
126 <h2 id="write_chrome_app_or_extension">Write Chrome App or Extension</h2> | 126 <h2 id="write_chrome_app_or_extension">Write Chrome App or Extension</h2> |
127 | 127 |
128 <h3 id="obtain_registration_id">Obtain registration ID</h3> | 128 <h3 id="obtain_registration_id">Obtain registration ID</h3> |
129 | 129 |
130 <p>Your app or extension needs to register with GCM servers before it can receiv
e | 130 <p>Your app or extension needs to register with GCM servers before it can receiv
e |
131 messages. When an app or extension registers, it receives a registration ID. | 131 messages. When an app or extension registers, it receives a registration ID. |
132 This is achieved by calling $(ref:gcm.register) and specifying a list of senders | 132 This is achieved by calling $(ref:gcm.register) and specifying a list of senders |
133 identified by project numbers from Google Developers Console. Your app or | 133 identified by project numbers from Google Developers Console. Your app or |
134 extension should pass a callback function to verify that the registration was | 134 extension should pass a callback function to verify that the registration was |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
227 <p>To send messages upstream, your app or extension should call $(ref:gcm.send)
with an | 227 <p>To send messages upstream, your app or extension should call $(ref:gcm.send)
with an |
228 object containing:</p> | 228 object containing:</p> |
229 | 229 |
230 <ul> | 230 <ul> |
231 <li>Message ID that identifies the message when it fails to be queued or | 231 <li>Message ID that identifies the message when it fails to be queued or |
232 delivered. The message ID can be any kind of string. However, it is | 232 delivered. The message ID can be any kind of string. However, it is |
233 recommended to stay unique across the lifetime of your app or extension, even | 233 recommended to stay unique across the lifetime of your app or extension, even |
234 after it restarts. If you use the same message ID, there may be a chance that | 234 after it restarts. If you use the same message ID, there may be a chance that |
235 the previous message gets overridden. If an auto-increment counter is used to | 235 the previous message gets overridden. If an auto-increment counter is used to |
236 create the message ID, your app or extension should persist the counter value | 236 create the message ID, your app or extension should persist the counter value |
237 via <a href="storage.html">chrome.storage</a> API and restore it when the app | 237 via <a href="storage">chrome.storage</a> API and restore it when the app |
238 reloads.</li> | 238 reloads.</li> |
239 <li>Destination ID that identifies the server. This is the project number from t
he | 239 <li>Destination ID that identifies the server. This is the project number from t
he |
240 Google Developers Console plus the suffix "@gcm.googleapis.com".</li> | 240 Google Developers Console plus the suffix "@gcm.googleapis.com".</li> |
241 <li>Data that consist of a list of string-to-string key value pairs (up to 4KB | 241 <li>Data that consist of a list of string-to-string key value pairs (up to 4KB |
242 total).</li> | 242 total).</li> |
243 <li>Time-to-live (TTL, optional). This property value must be a duration from 0
to | 243 <li>Time-to-live (TTL, optional). This property value must be a duration from 0
to |
244 2,419,200 seconds (4 weeks) and it corresponds to the maximum period of time | 244 2,419,200 seconds (4 weeks) and it corresponds to the maximum period of time |
245 for which GCM will store and try to deliver the message. If this property is | 245 for which GCM will store and try to deliver the message. If this property is |
246 not set, it is default to the maximum value. When a TTL is set to 0, GCM will | 246 not set, it is default to the maximum value. When a TTL is set to 0, GCM will |
247 try to deliver the message immediately. If the immediate effort fails, the | 247 try to deliver the message immediately. If the immediate effort fails, the |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
370 <li><strong>Unknown error occurred</strong>: this could happen due to any other
internal | 370 <li><strong>Unknown error occurred</strong>: this could happen due to any other
internal |
371 errors.</li> | 371 errors.</li> |
372 </ul> | 372 </ul> |
373 | 373 |
374 <h2 id="feedback">Feedback</h2> | 374 <h2 id="feedback">Feedback</h2> |
375 | 375 |
376 <p>You can provide feedback about Google Cloud Messaging and the gcm API through | 376 <p>You can provide feedback about Google Cloud Messaging and the gcm API through |
377 the Google Group <a href="https://groups.google.com/forum/#!forum/gcm-for-chrome
-feedback">GCM for Chrome | 377 the Google Group <a href="https://groups.google.com/forum/#!forum/gcm-for-chrome
-feedback">GCM for Chrome |
378 Feedback</a>. | 378 Feedback</a>. |
379 Use this group to ask for help, file bug reports, and request features.</p> | 379 Use this group to ask for help, file bug reports, and request features.</p> |
OLD | NEW |