| OLD | NEW |
| 1 <meta name="doc-family" content="apps"> | 1 <meta name="doc-family" content="apps"> |
| 2 <h1>Google Cloud Messaging for Chrome</h1> | 2 <h1>Google Cloud Messaging for Chrome</h1> |
| 3 | 3 |
| 4 <p class="note"> | 4 <p class="note"> |
| 5 If you are looking for the new Google Cloud Messaging API, please click | 5 If you are looking for the new Google Cloud Messaging API, please click |
| 6 <a href="cloudMessagingV2">here</a>. | 6 <a href="cloudMessagingV2">here</a>. |
| 7 </p> | 7 </p> |
| 8 | 8 |
| 9 <p> | 9 <p> |
| 10 Google Cloud Messaging for Chrome (GCM) is a service | 10 Google Cloud Messaging for Chrome (GCM) is a service |
| 11 for signed-in Chrome users | 11 for signed-in Chrome users |
| 12 that helps developers send message data from servers | 12 that helps developers send message data from servers |
| 13 to their Chrome apps and extensions. | 13 to their Chrome apps and extensions. |
| 14 The service is intended to wake up an app or extension, | 14 The service is intended to wake up an app or extension, |
| 15 and/or alert a user. | 15 and/or alert a user. |
| 16 For example, calendar updates could be pushed to users | 16 For example, calendar updates could be pushed to users |
| 17 even when their calendaring app isn't open. | 17 even when their calendaring app isn't open. |
| 18 </p> | 18 </p> |
| 19 | 19 |
| 20 <p>This document describes how to set up and use GCM. | 20 <p>This document describes how to set up and use GCM. |
| 21 For additional information see the reference documentation | 21 For additional information see the reference documentation |
| 22 for the <a href="pushMessaging.html">pushMessaging Chrome API</a> and the | 22 for the <a href="pushMessaging">pushMessaging Chrome API</a> and the |
| 23 <a href="gcm_server.html">GCM service</a>. | 23 <a href="gcm_server">GCM service</a>. |
| 24 To get help with GCM or to give us feedback, see <a href="#feedback">Feedback</a
>. | 24 To get help with GCM or to give us feedback, see <a href="#feedback">Feedback</a
>. |
| 25 </p> | 25 </p> |
| 26 | 26 |
| 27 <h2 id="one">How push messaging works</h2> | 27 <h2 id="one">How push messaging works</h2> |
| 28 | 28 |
| 29 <p> | 29 <p> |
| 30 At a glance, push messaging works like this: | 30 At a glance, push messaging works like this: |
| 31 </p> | 31 </p> |
| 32 | 32 |
| 33 <ol> | 33 <ol> |
| (...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 403 var notification = window.webkitNotifications.createNotification( | 403 var notification = window.webkitNotifications.createNotification( |
| 404 '', 'New notification', message.payload + " [" + message.subchannelId + "]")
; | 404 '', 'New notification', message.payload + " [" + message.subchannelId + "]")
; |
| 405 notification.show(); | 405 notification.show(); |
| 406 } | 406 } |
| 407 </pre> | 407 </pre> |
| 408 | 408 |
| 409 <p> | 409 <p> |
| 410 You need to add the "notifications" permission | 410 You need to add the "notifications" permission |
| 411 to <code>manifest.json</code> | 411 to <code>manifest.json</code> |
| 412 to use text notifications | 412 to use text notifications |
| 413 (see <a href="desktop_notifications.html">Desktop Notifications</a>): | 413 (see <a href="desktop_notifications">Desktop Notifications</a>): |
| 414 </p> | 414 </p> |
| 415 | 415 |
| 416 <pre data-filename="manifest.json"> | 416 <pre data-filename="manifest.json"> |
| 417 "permissions": [ | 417 "permissions": [ |
| 418 "pushMessaging", | 418 "pushMessaging", |
| 419 "notifications" | 419 "notifications" |
| 420 ] | 420 ] |
| 421 </pre> | 421 </pre> |
| 422 | 422 |
| 423 <h2 id="six">Error reference</h2> | 423 <h2 id="six">Error reference</h2> |
| (...skipping 24 matching lines...) Expand all Loading... |
| 448 | 448 |
| 449 <h2 id="test">Testing</h2> | 449 <h2 id="test">Testing</h2> |
| 450 | 450 |
| 451 <h3 id="test-local">Testing locally</h3> | 451 <h3 id="test-local">Testing locally</h3> |
| 452 | 452 |
| 453 <p> | 453 <p> |
| 454 To test push messaging locally: | 454 To test push messaging locally: |
| 455 </p> | 455 </p> |
| 456 | 456 |
| 457 <ol> | 457 <ol> |
| 458 <li><a href="packaging.html">Package</a> a test version of | 458 <li><a href="packaging">Package</a> a test version of |
| 459 your app or extension on the Extensions management page | 459 your app or extension on the Extensions management page |
| 460 (chrome://extensions). | 460 (chrome://extensions). |
| 461 Your app or extension doesn't need to be running; it just needs | 461 Your app or extension doesn't need to be running; it just needs |
| 462 to be installed.</li> | 462 to be installed.</li> |
| 463 | 463 |
| 464 <li>Get the channel ID at install time using | 464 <li>Get the channel ID at install time using |
| 465 {{?is_apps}}$(ref:app.runtime.onLaunched).{{/is_apps}} | 465 {{?is_apps}}$(ref:app.runtime.onLaunched).{{/is_apps}} |
| 466 {{^is_apps}}$(ref:runtime.onInstalled).{{/is_apps}}</li> | 466 {{^is_apps}}$(ref:runtime.onInstalled).{{/is_apps}}</li> |
| 467 | 467 |
| 468 <li>Use that channel ID on the server to send a test | 468 <li>Use that channel ID on the server to send a test |
| (...skipping 14 matching lines...) Expand all Loading... |
| 483 from sending messages to your app or extension without your permission. | 483 from sending messages to your app or extension without your permission. |
| 484 If your app or extension attempts to use the pushMessaging API and | 484 If your app or extension attempts to use the pushMessaging API and |
| 485 the ownership check fails, it will receive | 485 the ownership check fails, it will receive |
| 486 HTTP status code 500 (Internal Server Error). | 486 HTTP status code 500 (Internal Server Error). |
| 487 </p> | 487 </p> |
| 488 | 488 |
| 489 <p> | 489 <p> |
| 490 One circumstance in which the ownership check commonly fails is when you are | 490 One circumstance in which the ownership check commonly fails is when you are |
| 491 developing an app and you run the app without uploading it and re-downloading | 491 developing an app and you run the app without uploading it and re-downloading |
| 492 it from the Chrome Web Store. In this situation your app may not have a | 492 it from the Chrome Web Store. In this situation your app may not have a |
| 493 <a href="manifest/key.html">key</a> field in its manifest.json file. | 493 <a href="manifest/key">key</a> field in its manifest.json file. |
| 494 The <code>key</code> field gives an app its Chrome Web Store ID | 494 The <code>key</code> field gives an app its Chrome Web Store ID |
| 495 (a 32 character alphabetic code, such as "bafimiidcfafikaonocgmmcpbbhfjjik"). | 495 (a 32 character alphabetic code, such as "bafimiidcfafikaonocgmmcpbbhfjjik"). |
| 496 If you run a version of your app without a key, the app will use a | 496 If you run a version of your app without a key, the app will use a |
| 497 randomly generated ID that will not match the app's ID in the Chrome Web Store. | 497 randomly generated ID that will not match the app's ID in the Chrome Web Store. |
| 498 For example, if you upload your app to the Chrome Web Store from the directory | 498 For example, if you upload your app to the Chrome Web Store from the directory |
| 499 original_app_dir, then download the app and unpack it to downloaded_app_dir, | 499 original_app_dir, then download the app and unpack it to downloaded_app_dir, |
| 500 and then run the exact same app as an unpacked extension from original_app_dir, | 500 and then run the exact same app as an unpacked extension from original_app_dir, |
| 501 the manifest.json file of the app in original_app_dir would not have | 501 the manifest.json file of the app in original_app_dir would not have |
| 502 the downloaded key, and the app's ID would appear to be different than | 502 the downloaded key, and the app's ID would appear to be different than |
| 503 the ID of the downloaded app. | 503 the ID of the downloaded app. |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 548 you need to remove the key because the Store does not currently allow manifests | 548 you need to remove the key because the Store does not currently allow manifests |
| 549 with keys. | 549 with keys. |
| 550 </p> | 550 </p> |
| 551 | 551 |
| 552 <h2 id="feedback">Feedback</h2> | 552 <h2 id="feedback">Feedback</h2> |
| 553 | 553 |
| 554 <p>You can provide feedback about Google Cloud Messaging | 554 <p>You can provide feedback about Google Cloud Messaging |
| 555 and the pushMessaging API through the Google Group | 555 and the pushMessaging API through the Google Group |
| 556 <a target="_blank" href="https://groups.google.com/forum/#!forum/gcm-for-chrome-
feedback">GCM for Chrome feedback</a>. | 556 <a target="_blank" href="https://groups.google.com/forum/#!forum/gcm-for-chrome-
feedback">GCM for Chrome feedback</a>. |
| 557 Use this group to ask for help, file bug reports, and request features.</p> | 557 Use this group to ask for help, file bug reports, and request features.</p> |
| OLD | NEW |