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 |
mkearney1
2014/10/02 00:52:49
Replace 'here' with something more descriptive, li
jianli
2014/10/14 18:00:43
Done.
| |
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">here</a>. The mess age |
211 or extensions with one of the registration IDs. If your app or extension has | 148 specifies all of the registration IDs that are related to that user. When the |
212 been installed in more than one profiles in a single Chrome instance, all of | 149 GCM server receives the message, it routes the message to all instances of |
213 them can receive messages independently based on their unique registration IDs.< /p> | 150 Chrome running apps or extensions with one of the registration IDs. If your app |
151 or extension has been installed in more than one profiles in a single Chrome | |
152 instance, all of them can receive messages independently based on their unique | |
153 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 | |
mkearney1
2014/10/02 00:52:49
Same as comment above. Replace 'here' with somethi
jianli
2014/10/14 18:00:43
Done.
| |
172 should be set up to connect to GCM Cloud Connection Server as described | |
173 <a href="http://developer.android.com/google/gcm/ccs.html">here</a>.</p> | |
174 | |
230 <p>To send messages upstream, your app or extension should call $(ref:gcm.send) with an | 175 <p>To send messages upstream, your app or extension should call $(ref:gcm.send) with an |
231 object containing:</p> | 176 object containing:</p> |
232 | 177 |
233 <ul> | 178 <ul> |
234 <li>Message ID that identifies the message when it fails to be queued or | 179 <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 | 180 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 | 181 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 | 182 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 | 183 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 | 184 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 | 185 via <a href="storage.html">chrome.storage</a> API and restore it when the app |
241 reloads.</li> | 186 reloads.</li> |
242 <li>Destination ID that identifies the server. This is the project number from t he | 187 <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> | 188 <a href="https://cloud.google.com/console/project">Google Developers Console</a> plus the |
189 suffix "@gcm.googleapis.com".</li> | |
244 <li>Data that consist of a list of string-to-string key value pairs (up to 4KB | 190 <li>Data that consist of a list of string-to-string key value pairs (up to 4KB |
245 total).</li> | 191 total).</li> |
246 <li>Time-to-live (TTL, optional). This property value must be a duration from 0 to | 192 <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 | 193 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 | 194 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 | 195 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 | 196 to deliver the message immediately. If the immediate effort fails, the message |
251 message will be discarded.</li> | 197 will be discarded.</li> |
252 </ul> | 198 </ul> |
253 | 199 |
254 <p>When the callback passed in $(ref:gcm.send) is called without runtime error, it does | 200 <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 | 201 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 | 202 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, | 203 handle <code>chrome.runtime.lastError</code>. Please refer to <a href="#error_re ference">Error |
258 the $(ref:gcm.onSendError) will be fired.</p> | 204 reference</a> for possible error codes that could be |
205 returned.</p> | |
206 | |
207 <p>If the message fails to reach the destination within the specified TTL period , | |
208 for example due to network error, the $(ref:gcm.onSendError) will be fired. Your app | |
209 or extension can listen to this event and react to it, e.g. by trying to resend | |
210 the message. Please refer to <a href="#error_reference">Error reference</a> for | |
211 possible error codes that could be returned.</p> | |
259 | 212 |
260 <pre data-filename="background.js"><code> | 213 <pre data-filename="background.js"><code> |
261 // Substitute your own sender ID here. This is the project | 214 // Substitute your own sender ID here. This is the project |
262 // number you got from the Google Developers Console. | 215 // number you got from the Google Developers Console. |
263 var senderId = "Your-Sender-ID"; | 216 var senderId = "Your-Sender-ID"; |
264 | 217 |
265 // Make the message ID unique across the lifetime of your app. | 218 // Make the message ID unique across the lifetime of your app. |
266 // One way to achieve this is to use the auto-increment counter | 219 // One way to achieve this is to use the auto-increment counter |
267 // that is persisted to local storage. | 220 // that is persisted to local storage. |
268 | 221 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
305 | 258 |
306 // The message has been accepted for delivery. If the message | 259 // The message has been accepted for delivery. If the message |
307 // can not reach the destination, onSendError event will be | 260 // can not reach the destination, onSendError event will be |
308 // fired. | 261 // fired. |
309 }); | 262 }); |
310 } | 263 } |
311 | 264 |
312 function sendError(error) { | 265 function sendError(error) { |
313 console.log("Message " + error.messageId + | 266 console.log("Message " + error.messageId + |
314 " failed to be sent: " + error.errorMessage); | 267 " failed to be sent: " + error.errorMessage); |
315 } | 268 </code></pre> |
316 </code></pre> | 269 |
270 <blockquote> | |
271 <p>}</p> | |
272 </blockquote> | |
273 | |
274 <h2 id="advanced_topics">Advanced Topics</h2> | |
317 | 275 |
318 <h3 id="messages_deleted_event">Messages deleted event</h3> | 276 <h3 id="messages_deleted_event">Messages deleted event</h3> |
319 | 277 |
320 <p>GCM will store up to 100 non-collapsible messages. After that, all messages a re | 278 <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 | 279 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 | 280 $(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> | 281 behind. Your app or extension should respond by syncing with your application |
282 server to recover the discarded messages.</p> | |
324 | 283 |
325 <pre data-filename="background.js"><code> | 284 <pre data-filename="background.js"><code> |
326 chrome.gcm.onMessagesDeleted.addListener(messagesDeleted); | 285 chrome.gcm.onMessagesDeleted.addListener(messagesDeleted); |
327 | 286 |
328 function messagesDeleted() { | 287 function messagesDeleted() { |
329 // All messages have been discarded from GCM. Sync with | 288 // All messages have been discarded from GCM. Sync with |
330 // your application server to recover from the situation. | 289 // your application server to recover from the situation. |
331 } | 290 } |
332 </code></pre> | 291 </code></pre> |
333 | 292 |
334 <h3 id="collapsible_messages">Collapsible messages</h3> | 293 <h3 id="collapsible_messages">Collapsible messages</h3> |
335 | 294 |
336 <p>GCM messages are often a tickle, telling the app or extension to contact the | 295 <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 | 296 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 | 297 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 | 298 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 | 299 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 | 300 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 | 301 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 | 302 messages, please refer to <a href="http://developer.android.com/google/gcm/adv.h tml#collapsible">GCM Advance |
344 Topics</a>.</p> | 303 Topics</a>.</p> |
345 | 304 |
346 <h2 id="publish_your_app">Publish your app</h2> | 305 <h3 id="implement_gcm_server">Implement GCM Server</h3> |
347 | 306 |
mkearney1
2014/10/02 00:52:49
Again, make sure to state specifically that you ar
jianli
2014/10/14 18:00:43
Done.
| |
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 | 307 <p>Currently GCM provides two connection servers: |
349 Store</a>.</p> | 308 <a href="http://developer.android.com/google/gcm/http.html">HTTP</a> and |
309 <a href="http://developer.android.com/google/gcm/ccs.html">CCS</a> (XMPP). You c an use them | |
310 separately or in tandem. Please refer to <a href="http://developer.android.com/g oogle/gcm/server.html">GCM | |
311 Server</a> for details.</p> | |
350 | 312 |
351 <h2 id="error_reference">Error reference</h2> | 313 <h2 id="error_reference">Error reference</h2> |
352 | 314 |
353 <p>An error could occur when a gcm API function is called. Your app or extension | 315 <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 | 316 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> | 317 The error code will also be passed as a parameter to $(ref:gcm.onSendError) even t.</p> |
356 | 318 |
357 <p>Here's a brief summary of the gcm errors:</p> | 319 <p>Here's a brief summary of the gcm errors:</p> |
358 | 320 |
359 <ul> | 321 <ul> |
360 <li><strong>Function was called with invalid parameters</strong>: this could hap pen when gcm | 322 <li><strong>Function was called with invalid parameters</strong>: this could hap pen when gcm |
361 functions are called with bad parameters.</li> | 323 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 | 324 <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> | 325 from a profile that was not signed in.</li> |
364 <li><strong>Asynchronous operation is pending</strong>: this could happen when c ertain gcm | 326 <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 | 327 function is called again without waiting for the callback passed in previous |
366 function to be called.</li> | 328 function to be called.</li> |
367 <li><strong>Network error occurred</strong>: this could happen when GCM server f ails to reach | 329 <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> | 330 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 | 331 <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> | 332 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 | 333 <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> | 334 delivered within the specific time-to-live period.</li> |
373 <li><strong>Unknown error occurred</strong>: this could happen due to any other internal | 335 <li><strong>Unknown error occurred</strong>: this could happen due to any other internal |
374 errors.</li> | 336 errors.</li> |
375 </ul> | 337 </ul> |
376 | 338 |
377 <h2 id="feedback">Feedback</h2> | 339 <h2 id="feedback">Feedback</h2> |
378 | 340 |
379 <p>You can provide feedback about Google Cloud Messaging and the | 341 <p>You can provide feedback about Google Cloud Messaging and the |
380 <a href="gcm">chrome.gcm API</a> through | 342 <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 | 343 Feedback</a>. Use |
382 Feedback</a>. | 344 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 |