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 devices an
d |
5 Chrome instances to send and receive message data from servers. | 5 Chrome instances to send and receive message data from servers. The |
6 The <a href="gcm">chrome.gcm API</a> allows the Chrome apps or extensions | 6 <a href="gcm.html">chrome.gcm</a> API allows the Chrome apps or extensions to ac
cess |
7 to access the GCM service for the signed-in Chrome users. | 7 the GCM service for the signed-in Chrome users. The service works even if an app |
8 The service works even if an app or extension isn't currently running. | 8 or extension isn't currently running. For example, calendar updates could be |
9 For example, calendar updates could be pushed | 9 pushed to users even when their calendar app isn't open. </p> |
10 to users even when their calendar app isn't open. </p> | |
11 | 10 |
12 <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 |
13 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 |
14 of Service</a>.</p> | 13 of Service</a>.</p> |
15 | 14 |
16 <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 |
17 see the reference documentation for the <a href="gcm">GCM Chrome API</a> and | 16 see the reference documentation for the <a href="gcm.html">chrome.gcm</a> API an
d |
18 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 |
19 help with GCM or to give us feedback, please see | 18 help with GCM or to give us feedback, please see |
20 <a href="#feedback">Feedback</a>.</p> | 19 <a href="#feedback">Feedback</a>.</p> |
21 | 20 |
22 <p class="note"><strong>API Samples</strong>: Want to play with the code? Check
out the | 21 <p class="note"><strong>API Samples</strong>: Want to play with the code? Check
out the |
23 <a href="https://github.com/GoogleChrome/chrome-app-samples/tree/master/samples/
gcm-notifications">gcm-notifications</a> | 22 <a href="https://github.com/GoogleChrome/chrome-app-samples/tree/master/samples/
gcm-notifications">gcm-notifications</a> |
24 sample.</p> | 23 sample.</p> |
25 | 24 |
26 <h2 id="enable_gcm">Enable GCM</h2> | |
27 | |
28 <p>To use GCM for your app or extension, do the following:</p> | |
29 | |
30 <ol> | |
31 <li>Upload your app or extension client to the <a href="https://developers.googl
e.com/chrome/web-store/docs/publish">Chrome Web | |
32 Store</a>.</li> | |
33 <li>A user installs your app or extension.</li> | |
34 <li>Your app or extension client requests a registration ID using $(ref:gcm.regi
ster) | |
35 function and sends this ID to your server together with information | |
36 identifying the user. For more details, please see <a href="#obtain_registration
_id">Obtain registration | |
37 ID</a>.</li> | |
38 </ol> | |
39 | |
40 <h2 id="receive_a_message">Receive a message</h2> | |
41 | |
42 <p>At a glance, receiving a message works like this:</p> | |
43 | |
44 <ol> | |
45 <li>Your app or extension client should register a handler to receive the | |
46 $(ref:gcm.onMessage) event.</li> | |
47 <li>When your server sends a message to the user, it specifies all of the | |
48 registration IDs that are related to that user and passes the message to the | |
49 GCM service.</li> | |
50 <li>GCM servers route the message to all instances of Chrome running apps or | |
51 extensions with one of the registration IDs.</li> | |
52 <li>When the message arrives on the client, Chrome starts the app or extension, | |
53 if it is not already running, and calls the registered handler to process the | |
54 message.</li> | |
55 </ol> | |
56 | |
57 <p>For more details, please see <a href="#receive_messages">Receive messages</a>
.</p> | |
58 | |
59 <h2 id="send_a_message">Send a message</h2> | |
60 | |
61 <p>At a glance, sending a message works like this:</p> | |
62 | |
63 <ol> | |
64 <li>Your app or extension generates a unique message ID, so that it is possible | |
65 to find out which message failed to be queued or delivered.</li> | |
66 <li>Your app or extension calls $(ref:gcm.send) function with an object containi
ng | |
67 message ID, destination ID that identifies the server, and data that consist | |
68 of a list of key value pairs. In this step you can also provide an optional | |
69 time-to-live for the message.</li> | |
70 <li>The callback passed to $(ref:gcm.send) function will be called to notify the | |
71 result. Your app or extension should check $(ref:runtime.lastError) to find out
if | |
72 the message has been successfully queued for delivery. Please refer to <a href="
#error_reference">Error | |
73 reference</a> for possible error codes that could be | |
74 returned.</li> | |
75 <li>In cases that the queued message could not be delivered to the GCM server, | |
76 like network error, a $(ref:gcm.onSendError) event will be fired. Your app or | |
77 extension can listen to this event and react to it, e.g. by trying to resend | |
78 the message. Please refer to <a href="#error_reference">Error reference</a> for | |
79 possible error codes that could be returned.</li> | |
80 </ol> | |
81 | |
82 <p>For more details, please see <a href="#send_messages">Send messages</a>.</p> | |
83 | |
84 <p class="note"><strong>Display messages in rich notifications format:</strong><
br> | |
85 GCM and rich notifications API are a natural fit; | |
86 Use GCM to send and receive message data; use rich notifications to display | |
87 the data in the user's system tray | |
88 (see <a href="inform_users">Keep Users Informed</a>).</p> | |
89 | |
90 <h2 id="set_up_project">Set up project</h2> | 25 <h2 id="set_up_project">Set up project</h2> |
91 | 26 |
92 <h3 id="create_google_api_project">Create Google API project</h3> | 27 <h3 id="create_google_api_project">Create Google API project</h3> |
93 | 28 |
94 <ol> | 29 <ol> |
95 <li>Login to the <a href="https://cloud.google.com/console/project">Google Devel
opers | 30 <li>Login to the <a href="https://cloud.google.com/console/project">Google Devel
opers |
96 Console</a> using the same Google Account that you will use to upload your app o
r extension.</li> | 31 Console</a> using the same Google |
| 32 Account that you will use to upload your app or extension.</li> |
97 <li>If you haven't created an API project yet, click <strong>Create Project</str
ong>.</li> | 33 <li>If you haven't created an API project yet, click <strong>Create Project</str
ong>.</li> |
98 <li>Supply a project name and click <strong>Create</strong>.</li> | 34 <li>Supply a project name and click <strong>Create</strong>.</li> |
99 <li>Once the project has been created, a page appears that displays your project | 35 <li>Once the project has been created, a page appears that displays your project |
100 number. For example, <strong>Project Number: 670330094152</strong>.</li> | 36 number. For example, <strong>Project Number: 670330094152</strong>.</li> |
101 <li>Copy down your project number. You will use it later on as the GCM sender ID
.</li> | 37 <li>Copy down your project number. You will use it later on as the GCM sender ID
.</li> |
102 </ol> | 38 </ol> |
103 | 39 |
104 <h3 id="enable_the_gcm_service">Enable the GCM service</h3> | 40 <h3 id="enable_the_gcm_service">Enable the GCM service</h3> |
105 | 41 |
106 <ol> | 42 <ol> |
107 <li>In the sidebar on the left, select <strong>APIs & auth</strong>.</li> | 43 <li>In the sidebar on the left, select <strong>APIs</strong> under <strong>APIs
& auth</strong>.</li> |
108 <li>In the displayed list of APIs, turn the <strong>Google Cloud Messaging for | 44 <li>In the displayed list of APIs, turn the <strong>Google Cloud Messaging for |
109 Android</strong> toggle to ON.</li> | 45 Android</strong> toggle to ON.</li> |
110 </ol> | 46 </ol> |
111 | 47 |
112 <h2 id="set_up_chrome_app_or_extension">Set up Chrome App or Extension</h2> | 48 <h2 id="set_up_chrome_app_or_extension">Set up Chrome App or Extension</h2> |
113 | 49 |
114 <h3 id="add_permission_to_manifest">Add permission to manifest</h3> | 50 <h3 id="add_permission_to_manifest">Add permission to manifest</h3> |
115 | 51 |
116 <p>To use the gcm service, you must declare the <code>gcm</code> permission in | 52 <p>To use the gcm service, you must declare the <code>gcm</code> permission in |
117 <code>manifest.json</code>.</p> | 53 <code>manifest.json</code>.</p> |
118 | 54 |
119 <pre data-filename="manifest.json"><code> | 55 <pre data-filename="manifest.json"><code> |
120 "permissions": [ | 56 "permissions": [ |
121 "gcm", "storage", ... | 57 "gcm", ... // Other permissions, like "storage" |
122 ] | 58 ] |
123 </code></pre> | 59 </code></pre> |
124 | 60 |
125 <p>Please note that the <code>storage</code> permission is also provided here be
cause the | 61 <p>Please note that running sample code below requires the <code>storage</code>
permission as |
126 sample codes below needs to persist some data via the | 62 well in order to persist some data via the <a href="storage.html">chrome.storage
</a> |
127 <a href="storage">chrome.storage</a> API.</p> | 63 API.</p> |
128 | 64 |
129 <h2 id="write_chrome_app_or_extension">Write Chrome App or Extension</h2> | 65 <h2 id="write_chrome_app_or_extension">Write Chrome App or Extension</h2> |
130 | 66 |
131 <h3 id="obtain_registration_id">Obtain registration ID</h3> | 67 <h3 id="obtain_gcm_registration_id">Obtain GCM registration ID</h3> |
132 | 68 |
133 <p>Your app or extension needs to register with GCM servers before it can receiv
e | 69 <p>Your app or extension needs to register with GCM servers before it can receiv
e |
134 messages. When an app or extension registers, it receives a registration ID. | 70 messages. This is achieved by calling $(ref:gcm.register) and passing a list of |
135 This is achieved by calling $(ref:gcm.register) and specifying a list of senders | 71 senders identified by project numbers from <a href="https://cloud.google.com/con
sole/project">Google Developers |
136 identified by project numbers from Google Developers Console. Your app or | 72 Console</a>. Your app or extension should |
137 extension should pass a callback function to verify that the registration was | 73 pass a callback function to verify if the registration succeeded or not, by |
138 successful. If successful, the received registration ID should be sent back to | 74 checking whether the error is set on <code>chrome.runtime.lastError</code> prope
rty. If the |
139 your application server in a secure way, for example, via https. Otherwise, your | 75 registration is successful, an app or extension receives a registration ID, |
140 app or extension should handle the error identified by | 76 which should be sent back to your application server in a secure way, for |
141 <code>chrome.runtime.lastError</code> and retry later.</p> | 77 example, via https. Otherwise, your app or extension should handle the error |
| 78 identified by <code>chrome.runtime.lastError</code> and retry later.</p> |
142 | 79 |
143 <p>If your app or extension wishes to receive messages from the different sender
s, | 80 <p>If your app or extension wishes to receive messages from the different sender
s, |
144 it can call $(ref:gcm.register) again with the new sender list and the new | 81 it can call $(ref:gcm.register) again with the new sender list and the new |
145 registration ID will be returned.</p> | 82 registration ID will be returned.</p> |
146 | 83 |
147 <pre data-filename="background.js"><code> | 84 <pre data-filename="background.js"><code> |
148 function registerCallback(registrationId) { | 85 function registerCallback(registrationId) { |
149 if (chrome.runtime.lastError) { | 86 if (chrome.runtime.lastError) { |
150 // When the registration fails, handle the error and retry the | 87 // When the registration fails, handle the error and retry the |
151 // registration later. | 88 // registration later. |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 } | 135 } |
199 | 136 |
200 chrome.gcm.unregister(unregisterCallback); | 137 chrome.gcm.unregister(unregisterCallback); |
201 </code></pre> | 138 </code></pre> |
202 | 139 |
203 <p>Your app or extension is automatically unregistered from the GCM service when
a | 140 <p>Your app or extension is automatically unregistered from the GCM service when
a |
204 user uninstalls it.</p> | 141 user uninstalls it.</p> |
205 | 142 |
206 <h3 id="receive_messages">Receive messages</h3> | 143 <h3 id="receive_messages">Receive messages</h3> |
207 | 144 |
208 <p>When your server sends a message to the user, it specifies all of the | 145 <p>When your server wants to send a message to the user, it needs to connect to
a |
209 registration IDs that are related to that user and passes the message to the GCM | 146 GCM connection server in one of two ways as described in the Android |
210 service. GCM servers route the message to all instances of Chrome running apps | 147 <a href="http://developer.android.com/google/gcm/server.html">Implementing GCM S
erver</a> |
211 or extensions with one of the registration IDs. If your app or extension has | 148 document. The message specifies all of the registration IDs that are related to |
212 been installed in more than one profiles in a single Chrome instance, all of | 149 that user. When the GCM server receives the message, it routes the message to |
213 them can receive messages independently based on their unique registration IDs.<
/p> | 150 all instances of Chrome running apps or extensions with one of the registration |
| 151 IDs. If your app or extension has been installed in more than one profiles in a |
| 152 single Chrome instance, all of them can receive messages independently based on |
| 153 their unique registration IDs.</p> |
214 | 154 |
215 <p>Messages from the server are delivered via the $(ref:gcm.onMessage) event. Yo
ur app | 155 <p>Messages from the server are delivered via the $(ref:gcm.onMessage) event. Yo
ur app |
216 or extension must register a handler to receive this event.</p> | 156 or extension must register a handler to receive this event.</p> |
217 | 157 |
218 <pre data-filename="background.js"><code> | 158 <pre data-filename="background.js"><code> |
219 chrome.gcm.onMessage.addListener(function(message) { | 159 chrome.gcm.onMessage.addListener(function(message) { |
220 // A message is an object with a data property that | 160 // A message is an object with a data property that |
221 // consists of key-value pairs. | 161 // consists of key-value pairs. |
222 }); | 162 }); |
223 </code></pre> | 163 </code></pre> |
224 | 164 |
225 <p>As long as Chrome is running, even if the extension or app is not running, it
is | 165 <p>As long as Chrome is running, even if the extension or app is not running, it
is |
226 woken up to deliver a message.</p> | 166 woken up to deliver a message.</p> |
227 | 167 |
228 <h3 id="send_messages">Send messages</h3> | 168 <h3 id="send_messages">Send messages</h3> |
229 | 169 |
| 170 <p>In addition to delivering push messages from your server to the client, the G
CM |
| 171 supports sending upstream messages from the client to your server. Your server |
| 172 should be set up to connect to GCM Cloud Connection Server as described in the |
| 173 Android <a href="http://developer.android.com/google/gcm/ccs.html">GCM Cloud Con
nection |
| 174 Server</a> document.</p> |
| 175 |
230 <p>To send messages upstream, your app or extension should call $(ref:gcm.send)
with an | 176 <p>To send messages upstream, your app or extension should call $(ref:gcm.send)
with an |
231 object containing:</p> | 177 object containing:</p> |
232 | 178 |
233 <ul> | 179 <ul> |
234 <li>Message ID that identifies the message when it fails to be queued or | 180 <li>Message ID that identifies the message when it fails to be queued or |
235 delivered. The message ID can be any kind of string. However, it is | 181 delivered. The message ID can be any kind of string. However, it is |
236 recommended to stay unique across the lifetime of your app or extension, even | 182 recommended to stay unique across the lifetime of your app or extension, even |
237 after it restarts. If you use the same message ID, there may be a chance that | 183 after it restarts. If you use the same message ID, there may be a chance that |
238 the previous message gets overridden. If an auto-increment counter is used to | 184 the previous message gets overridden. If an auto-increment counter is used to |
239 create the message ID, your app or extension should persist the counter value | 185 create the message ID, your app or extension should persist the counter value |
240 via <a href="storage">chrome.storage</a> API and restore it when the app | 186 via <a href="storage.html">chrome.storage</a> API and restore it when the app |
241 reloads.</li> | 187 reloads.</li> |
242 <li>Destination ID that identifies the server. This is the project number from t
he | 188 <li>Destination ID that identifies the server. This is the project number from t
he |
243 Google Developers Console plus the suffix "@gcm.googleapis.com".</li> | 189 <a href="https://cloud.google.com/console/project">Google Developers Console</a>
plus the |
| 190 suffix "@gcm.googleapis.com".</li> |
244 <li>Data that consist of a list of string-to-string key value pairs (up to 4KB | 191 <li>Data that consist of a list of string-to-string key value pairs (up to 4KB |
245 total).</li> | 192 total).</li> |
246 <li>Time-to-live (TTL, optional). This property value must be a duration from 0
to | 193 <li>Time-to-live (TTL, optional). This property value must be a duration from 0
to |
247 2,419,200 seconds (4 weeks) and it corresponds to the maximum period of time | 194 86,400 seconds (1 day) and it corresponds to the maximum period of time for |
248 for which GCM will store and try to deliver the message. If this property is | 195 which GCM will store and try to deliver the message. If this property is not |
249 not set, it is default to the maximum value. When a TTL is set to 0, GCM will | 196 set, it is default to the maximum value. When a TTL is set to 0, GCM will try |
250 try to deliver the message immediately. If the immediate effort fails, the | 197 to deliver the message immediately. If the immediate effort fails, the message |
251 message will be discarded.</li> | 198 will be discarded.</li> |
252 </ul> | 199 </ul> |
253 | 200 |
254 <p>When the callback passed in $(ref:gcm.send) is called without runtime error,
it does | 201 <p>When the callback passed in $(ref:gcm.send) is called without runtime error,
it does |
255 not mean that the message was already delivered to the GCM server. Rather, it | 202 not mean that the message was already delivered to the GCM server. Rather, it |
256 means that it was queued for delivery. If the message fails to reach the | 203 means that it was queued for delivery. Your app or extension should check and |
257 destination within the specified TTL period, for example due to network error, | 204 handle <code>chrome.runtime.lastError</code>. Please refer to <a href="#error_re
ference">Error |
258 the $(ref:gcm.onSendError) will be fired.</p> | 205 reference</a> for possible error codes that could be |
| 206 returned.</p> |
| 207 |
| 208 <p>If the message fails to reach the destination within the specified TTL period
, |
| 209 for example due to network error, the $(ref:gcm.onSendError) will be fired. Your
app |
| 210 or extension can listen to this event and react to it, e.g. by trying to resend |
| 211 the message. Please refer to <a href="#error_reference">Error reference</a> for |
| 212 possible error codes that could be returned.</p> |
259 | 213 |
260 <pre data-filename="background.js"><code> | 214 <pre data-filename="background.js"><code> |
261 // Substitute your own sender ID here. This is the project | 215 // Substitute your own sender ID here. This is the project |
262 // number you got from the Google Developers Console. | 216 // number you got from the Google Developers Console. |
263 var senderId = "Your-Sender-ID"; | 217 var senderId = "Your-Sender-ID"; |
264 | 218 |
265 // Make the message ID unique across the lifetime of your app. | 219 // Make the message ID unique across the lifetime of your app. |
266 // One way to achieve this is to use the auto-increment counter | 220 // One way to achieve this is to use the auto-increment counter |
267 // that is persisted to local storage. | 221 // that is persisted to local storage. |
268 | 222 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
305 | 259 |
306 // The message has been accepted for delivery. If the message | 260 // The message has been accepted for delivery. If the message |
307 // can not reach the destination, onSendError event will be | 261 // can not reach the destination, onSendError event will be |
308 // fired. | 262 // fired. |
309 }); | 263 }); |
310 } | 264 } |
311 | 265 |
312 function sendError(error) { | 266 function sendError(error) { |
313 console.log("Message " + error.messageId + | 267 console.log("Message " + error.messageId + |
314 " failed to be sent: " + error.errorMessage); | 268 " failed to be sent: " + error.errorMessage); |
315 } | 269 </code></pre> |
316 </code></pre> | 270 |
| 271 <blockquote> |
| 272 <p>}</p> |
| 273 </blockquote> |
| 274 |
| 275 <h2 id="advanced_topics">Advanced Topics</h2> |
317 | 276 |
318 <h3 id="messages_deleted_event">Messages deleted event</h3> | 277 <h3 id="messages_deleted_event">Messages deleted event</h3> |
319 | 278 |
320 <p>GCM will store up to 100 non-collapsible messages. After that, all messages a
re | 279 <p>GCM will store up to 100 non-collapsible messages that are sent from your ser
ver |
321 discarded from GCM, and an event $(ref:gcm.onMessagesDeleted) will be fired, whi
ch | 280 to your client. After that, all messages are discarded from GCM, and an event |
322 tells the client that it falls behind. Your app or extension should respond by | 281 $(ref:gcm.onMessagesDeleted) will be fired, which tells the client that it falls |
323 syncing with your application server to recover the discarded messages.</p> | 282 behind. Your app or extension should respond by syncing with your application |
| 283 server to recover the discarded messages.</p> |
324 | 284 |
325 <pre data-filename="background.js"><code> | 285 <pre data-filename="background.js"><code> |
326 chrome.gcm.onMessagesDeleted.addListener(messagesDeleted); | 286 chrome.gcm.onMessagesDeleted.addListener(messagesDeleted); |
327 | 287 |
328 function messagesDeleted() { | 288 function messagesDeleted() { |
329 // All messages have been discarded from GCM. Sync with | 289 // All messages have been discarded from GCM. Sync with |
330 // your application server to recover from the situation. | 290 // your application server to recover from the situation. |
331 } | 291 } |
332 </code></pre> | 292 </code></pre> |
333 | 293 |
334 <h3 id="collapsible_messages">Collapsible messages</h3> | 294 <h3 id="collapsible_messages">Collapsible messages</h3> |
335 | 295 |
336 <p>GCM messages are often a tickle, telling the app or extension to contact the | 296 <p>GCM messages are often a tickle, telling the app or extension to contact the |
337 server for fresh data. In GCM, it's possible to create collapsible messages for | 297 server for fresh data. In GCM, it's possible to create collapsible messages for |
338 this situation, wherein new messages replace older ones. When a collapse key is | 298 this situation, wherein new messages replace older ones. When a collapse key is |
339 provided and multiple messages are queued up in the GCM servers for the same | 299 provided and multiple messages are queued up in the GCM servers for the same |
340 user, only the last one with any given collapse key is delivered to your app or | 300 user, only the last one with any given collapse key is delivered to your app or |
341 extension. As a result the <code>message</code> object passed to the $(ref:gcm.o
nMessage) event | 301 extension. As a result the <code>message</code> object passed to the $(ref:gcm.o
nMessage) event |
342 will contain a <code>collapseKey</code>field. For more details about sending col
lapsible | 302 will contain a <code>collapseKey</code>field. For more details about sending col
lapsible |
343 messages, please refer to <a href="http://developer.android.com/google/gcm/adv.h
tml#collapsible">GCM Advance | 303 messages, please refer to the Android <a href="http://developer.android.com/goog
le/gcm/adv.html#collapsible">GCM Advanced |
344 Topics</a>.</p> | 304 Topics</a> document.</p> |
345 | 305 |
346 <h2 id="publish_your_app">Publish your app</h2> | 306 <h3 id="implement_gcm_server">Implement GCM Server</h3> |
347 | 307 |
348 <p>To use the GCM service, you must publish your app in the <a href="https://dev
elopers.google.com/chrome/web-store/docs/publish">Chrome Web | 308 <p>Currently GCM provides two connection servers: <a href="http://developer.andr
oid.com/google/gcm/http.html">GCM HTTP Connection |
349 Store</a>.</p> | 309 Server</a> and <a href="http://developer.android.com/google/gcm/ccs.html">GCM Cl
oud |
| 310 Connection Server (XMPP)</a>. You |
| 311 can use them separately or in tandem. Please refer to the Android <a href="http:
//developer.android.com/google/gcm/server.html">Implementing |
| 312 GCM Server</a> for details.</p> |
350 | 313 |
351 <h2 id="error_reference">Error reference</h2> | 314 <h2 id="error_reference">Error reference</h2> |
352 | 315 |
353 <p>An error could occur when a gcm API function is called. Your app or extension | 316 <p>An error could occur when a gcm API function is called. Your app or extension |
354 should check $(ref:runtime.lastError) for more information in your callback. The | 317 should check <code>chrome.runtime.lastError</code> for more information in your
callback. |
355 error code will also be passed as a parameter to $(ref:gcm.onSendError) event.</
p> | 318 The error code will also be passed as a parameter to $(ref:gcm.onSendError) even
t.</p> |
356 | 319 |
357 <p>Here's a brief summary of the gcm errors:</p> | 320 <p>Here's a brief summary of the gcm errors:</p> |
358 | 321 |
359 <ul> | 322 <ul> |
360 <li><strong>Function was called with invalid parameters</strong>: this could hap
pen when gcm | 323 <li><strong>Function was called with invalid parameters</strong>: this could hap
pen when gcm |
361 functions are called with bad parameters.</li> | 324 functions are called with bad parameters.</li> |
362 <li><strong>Profile was not signed in</strong>: this could happen when gcm funct
ions are called | 325 <li><strong>Profile was not signed in</strong>: this could happen when gcm funct
ions are called |
363 from a profile that was not signed in.</li> | 326 from a profile that was not signed in.</li> |
364 <li><strong>Asynchronous operation is pending</strong>: this could happen when c
ertain gcm | 327 <li><strong>Asynchronous operation is pending</strong>: this could happen when c
ertain gcm |
365 function is called again without waiting for the callback passed in previous | 328 function is called again without waiting for the callback passed in previous |
366 function to be called.</li> | 329 function to be called.</li> |
367 <li><strong>Network error occurred</strong>: this could happen when GCM server f
ails to reach | 330 <li><strong>Network error occurred</strong>: this could happen when GCM server f
ails to reach |
368 due to network problem, like losing Internet connection.</li> | 331 due to network problem, like losing Internet connection.</li> |
369 <li><strong>Server error occurred</strong>: this could happen when GCM server fa
ils to reach | 332 <li><strong>Server error occurred</strong>: this could happen when GCM server fa
ils to reach |
370 due to server problem, like server busy.</li> | 333 due to server problem, like server busy.</li> |
371 <li><strong>Time-to-live exceeded</strong>: this could happen when a message cou
ld not be | 334 <li><strong>Time-to-live exceeded</strong>: this could happen when a message cou
ld not be |
372 delivered within the specific time-to-live period.</li> | 335 delivered within the specific time-to-live period.</li> |
373 <li><strong>Unknown error occurred</strong>: this could happen due to any other
internal | 336 <li><strong>Unknown error occurred</strong>: this could happen due to any other
internal |
374 errors.</li> | 337 errors.</li> |
375 </ul> | 338 </ul> |
376 | 339 |
377 <h2 id="feedback">Feedback</h2> | 340 <h2 id="feedback">Feedback</h2> |
378 | 341 |
379 <p>You can provide feedback about Google Cloud Messaging and the | 342 <p>You can provide feedback about Google Cloud Messaging and the |
380 <a href="gcm">chrome.gcm API</a> through | 343 <a href="gcm.html">chrome.gcm</a> API through the Google Group <a href="https://
groups.google.com/forum/#!forum/gcm-for-chrome-feedback">GCM for Chrome |
381 the Google Group <a href="https://groups.google.com/forum/#!forum/gcm-for-chrome
-feedback">GCM for Chrome | 344 Feedback</a>. Use |
382 Feedback</a>. | 345 this group to ask for help, file bug reports, and request features.</p> |
383 Use this group to ask for help, file bug reports, and request features.</p> | |
OLD | NEW |