Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(88)

Side by Side Diff: chrome/common/extensions/docs/templates/articles/cloudMessaging.html

Issue 12104003: Updated GCM for Chrome docs (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/common/extensions/docs/templates/articles/gcm_server.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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> 4 <p>
5 Google Cloud Messaging for Chrome (GCM) is a service 5 Google Cloud Messaging for Chrome (GCM) is a service
6 for signed-in Chrome users 6 for signed-in Chrome users
7 that helps developers send message data from servers 7 that helps developers send message data from servers
8 to their Chrome apps and extensions. 8 to their Chrome apps and extensions.
9 The service is intended to wake-up an app or extension, 9 The service is intended to wake up an app or extension,
10 and/or alert a user. 10 and/or alert a user.
11 For example, calendar updates could be pushed to users 11 For example, calendar updates could be pushed to users
12 even when their calendaring app isn't open. 12 even when their calendaring app isn't open.
13 </p> 13 </p>
14 14
15 <p>This document describes how the service works and 15 <p>This document describes how the service works and
16 provides very basic examples on how to use the service. 16 provides very basic examples on how to use the service.
17 To learn more about GCM, 17 To learn more about GCM,
18 read the API reference for the <a href="pushMessaging.html">pushMessaging Chrome API</a> and the 18 read the API reference for the <a href="pushMessaging.html">pushMessaging Chrome API</a> and the
19 <a href="gcm_server.html">GCM service</a>. 19 <a href="gcm_server.html">GCM service</a>.
20 </p> 20 </p>
21 21
22 <h2 id="one">How it works</h2> 22 <h2 id="one">How it works</h2>
23 23
24 <p> 24 <p>
25 At a glance, push messaging works like this: 25 At a glance, push messaging works like this:
26 </p> 26 </p>
27 27
28 <ul> 28 <ol>
29 <li>You upload your app or extension client to the Chrome Web Store.</li> 29 <li>You upload your app or extension client to the Chrome Web Store.</li>
30 <li>A user installs your app or extension.</li> 30 <li>A user installs your app or extension.</li>
31 <li>Your app or extension client requests the user's channel ID 31 <li>Your app or extension client requests the user's channel ID
32 and sends this ID to your server.</li> 32 and sends this ID to your server.</li>
33 <li>Your app or extension server sends a message 33 <li>Your app or extension server sends a message
34 to the push messaging service.</li> 34 to the push messaging service.</li>
35 <li>The push messaging service routes the message 35 <li>The push messaging service routes the message
36 to all instances of Chrome where the user is signed in.</li> 36 to all instances of Chrome where the user is signed in.</li>
37 <li>When the app or extension starts, 37 <li>When the app or extension starts,
38 it needs to register a handler to receive the 38 it needs to register a handler to receive the
39 $ref:pushMessaging.onMessage event.</li> 39 $ref:pushMessaging.onMessage event.</li>
40 <li>When the message arrives on the client, 40 <li>When the message arrives on the client,
41 Chrome will start the app or extension, if it is not already running, 41 Chrome starts the app or extension, if it is not already running,
42 and call the registered handler.</li> 42 and calls the registered handler.</li>
43 </ul> 43 </ol>
44 44
45 <p> 45 <p>
46 Diving in a bit more, 46 Diving in a bit more,
47 the Chrome Web Store assigns your newly published app 47 the Chrome Web Store assigns your newly published app
48 or extension a unique app ID. 48 or extension a unique app ID.
49 When a user installs your app or extension, 49 When a user installs your app or extension,
50 the client needs to call $ref:pushMessaging.getChannelId. 50 the client needs to call $ref:pushMessaging.getChannelId.
51 The push messaging service returns a channel ID to the client; 51 The push messaging service returns a channel ID to the client;
52 this ID is specifically linked to your app ID and to the user. 52 this ID is specifically linked to your app ID and to the user.
53 Whatever method your client uses to send the channel ID to the server, 53 Whatever method your client uses to send the channel ID to the server,
54 it must be secured (https, for instance). 54 it must be secured (https, for instance).
55 For example, 55 For example,
56 the client could send an XHR request 56 the client could send an XHR request
57 to a RESTful API on your server. 57 to a RESTful API on your server.
58 </p> 58 </p>
59 59
60 <p> 60 <p>
61 As long as Chrome is running in the background or foreground, 61 As long as Chrome is running in the background or foreground,
62 even if the extension or app is not running, 62 even if the extension or app is not running,
63 it will be woken up to deliver a message. 63 it is woken up to deliver a message.
64 For this to work, 64 For this to work,
65 your app or extension must register a handler to receive the event, 65 your app or extension must register a handler to receive the event,
66 similar to how they’d register for launch events. 66 similar to how they’d register for launch events.
67 </p> 67 </p>
68 68
69 <p> 69 <p>
70 Your app/extension server is responsible 70 Your app/extension server is responsible
71 for sending a push message to the service. 71 for sending a push message to the service.
72 In all push message requests, 72 In all push message requests,
73 your server must include the user's channel ID 73 your server must include the user's channel ID
74 and a valid OAuth2.0 access token: 74 and a valid OAuth 2.0 access token:
75 the access token authorizes use of the service and 75 the access token authorizes use of the service and
76 the channel ID identifies the user and app to receive the message. 76 the channel ID identifies the user and app to receive the message.
77 </p> 77 </p>
78 78
79 <p> 79 <p>
80 Any messages sent will be delivered 80 Any messages sent are delivered
81 to all instances of that application installed 81 to all instances of that application installed
82 in a Chrome profile signed in as that user. 82 in a Chrome profile signed in as that user.
83 The most recent message sent on each subchannel will automatically be queued 83 The most recent message sent on each subchannel is automatically queued
84 for delivery to instances of Chrome which are not connected to the push 84 for delivery to instances of Chrome which are not connected to the push
85 messaging service at the time. If multiple messages are sent on one subchannel 85 messaging service at the time. If multiple messages are sent on one subchannel
86 while Chrome is disconnected, then Chrome may only receive the last one sent 86 while Chrome is disconnected, then Chrome may only receive the last one sent
87 when it reconnects. 87 when it reconnects.
88 </p> 88 </p>
89 89
90 <p> 90 <p>
91 Subchannels can also be used to implement priority schemes. 91 Subchannels can also be used to implement priority schemes.
92 For example, 92 For example,
93 if you had an instant messaging app, 93 if you had an instant messaging app,
94 requests for a phone call or video chat can go through immediately, 94 requests for a phone call or video chat can go through immediately,
95 instead of waiting for all the backed up chat messages to be cleared. 95 instead of waiting for all the backed up chat messages to be cleared.
96 </p> 96 </p>
97 97
98 <h2 id="checklist">To Do Checklist</h2> 98 <h2 id="checklist">To Do Checklist</h2>
99 99
100 <p> 100 <p>
101 Here's a quick checklist of what you need to do 101 Here's a quick checklist of what you need to do
102 to use the push messaging service 102 to use the push messaging service
103 (the remainder of this doc covers the steps in detail): 103 (the remainder of this doc covers the steps in detail):
104 </p> 104 </p>
105 105
106 <ul> 106 <ol>
107 <li>Register your app or extension: 107 <li>Register your app or extension:
108 <ul> 108 <ul>
109 <li>Create the client ID in the Google API console.</li> 109 <li>Create the client ID in the Google APIs Console.</li>
110 <li>Get the refresh token to setup authorization to use the service.</li> 110 <li>Get the refresh token to set up authorization to use the service.</li>
111 </ul> 111 </ul>
112 </li> 112 </li>
113 <li>Set up your app or extension to use the service: 113 <li>Set up your app or extension to use the service:
114 <ul> 114 <ul>
115 <li>Add the permission to the manifest.</li> 115 <li>Add the permission to the manifest.</li>
116 <li>Include a call to <code>getChannelId</code> 116 <li>Include a call to <code>getChannelId</code>
117 » for any user who will receive a message.</li> 117 for any user who is to receive a message.</li>
118 <li>Register a handler to receive the 118 <li>Register a handler to receive the
119 <code>onMessage</code> event.</li> 119 <code>onMessage</code> event.</li>
120 </ul> 120 </ul>
121 </li> 121 </li>
122 <li>Publish and get whitelisted. </li> 122 <li>Publish and get whitelisted. </li>
123 <li>Use refresh token to get a valid access token.</li> 123 <li>Use refresh token to get a valid access token.</li>
124 <li>Send message to user.</li> 124 <li>Send message to user.</li>
125 </ul> 125 </ol>
126 126
127 <h2 id="two">Register app or extension</h2> 127 <h2 id="two">Register app or extension</h2>
128 128
129 <h3 id="clientid">Create client ID</h3> 129 <h3 id="clientid">Create client ID</h3>
130 130
131 <p> 131 <p>
132 Complete the following steps to create the client ID: 132 Complete the following steps to create the client ID:
133 </p> 133 </p>
134 134
135 <ol> 135 <ol>
136 <li>Login to the 136 <li>Login to the
137 <a href="https://code.google.com/apis/console/">Google APIs Console</a> 137 <a href="https://code.google.com/apis/console/">Google APIs Console</a>
138 using the same Google account that you will use to upload your app.</li> 138 using the same Google Account that you will use to upload your app.</li>
139 <li> Create a new project by expanding the drop-down menu in the top-left corn er 139 <li> Create a new project by expanding the drop-down menu in the top-left corn er
140 and selecting the <strong>Create...</strong> menu item.</li> 140 and selecting the <strong>Create...</strong> menu item.</li>
141 <li>Go to the "Services" navigation menu item and 141 <li>Go to the "Services" navigation menu item and
142 turn on the <strong>Google Cloud Messaging for Chrome API</strong>.</li> 142 turn on the <strong>Google Cloud Messaging for Chrome API</strong>.</li>
143 <li>Go to the "API Access" navigation menu item and click on the 143 <li>Go to the "API Access" pane and click on the
144 <strong>Create an OAuth 2.0 client ID...</strong> blue button.</li> 144 <strong>Create an OAuth 2.0 client ID...</strong> blue button.</li>
145 <li>Enter the requested branding information, if needed</li> 145 <li>Enter the requested branding information, if needed</li>
146 <li>For “Application type” select “Web application”.</li> 146 <li>For “Application type” select “Web application”.</li>
147 <li>Click "more options" beside "Your site or hostname" 147 <li>Click "more options" beside "Your site or hostname"
148 and under "Authorized Redirect URIs", enter the following URL: 148 and under "Authorized Redirect URIs", enter the following URL:
149 <code>https://developers.google.com/oauthplayground</code>.</li> 149 <code>https://developers.google.com/oauthplayground</code>.</li>
150 <li>Click "Create client ID" button.</li> 150 <li>Click "Create client ID" button.</li>
151 </ol> 151 </ol>
152 152
153 <p> 153 <p>
154 The client ID and the client secret 154 The client ID and the client secret
155 from this step will be used in further steps. 155 from this step are used in further steps.
156 Be sure to keep the client ID and secret in a safe place, 156 Be sure to keep the client ID and secret in a safe place,
157 and don't expose them to outsiders. 157 and don't expose them to outsiders.
158 </p> 158 </p>
159 159
160 <h3 id="refresh">Get refresh token</h3> 160 <h3 id="refresh">Get refresh token</h3>
161 161
162 <p> 162 <p>
163 You need two types of OAuth 2.0 tokens to authorize 163 You need two types of OAuth 2.0 tokens to authorize
164 each call to the push messaging service: 164 each call to the push messaging service:
165 the refresh token and the access token. 165 the refresh token and the access token.
166 The access token authorizes each call to the service; 166 The access token authorizes each call to the service;
167 however, this token expires after about an hour. 167 however, this token expires after about an hour.
168 The refresh token is used 168 The refresh token is used
169 to 'refresh' the access token over time. 169 to 'refresh' the access token over time.
170 These tokens are scoped to only send messages on behalf 170 These tokens are scoped to only send messages on behalf
171 of your application or extension and nothing else. 171 of your application or extension and nothing else.
172 </p> 172 </p>
173 173
174 <p> 174 <p>
175 To get the refresh token and initial access token: 175 To get the refresh token and initial access token:
176 </p> 176 </p>
177 177
178 <ol> 178 <ol>
179 <li>Open an Incognito window in Chrome; 179 <li>Open an Incognito window in Chrome;
180 this ensures that you are logged into the correct Google account. 180 this ensures that you are logged into the correct Google Account.
181 If you only have one Google account, 181 If you only have one Google Account,
182 you don't need to use an incognito window.</li> 182 you don't need to use an incognito window.</li>
183 <li>Go to the 183 <li>Go to the
184 <a href="https://developers.google.com/oauthplayground/">OAuth2.0 Playground</ a>.</li> 184 <a href="https://developers.google.com/oauthplayground/">OAuth 2.0 Playground< /a>.</li>
185 <li>Click the <img src="{{static}}/images/gearsicon.png" width="29" height="23 " align="middle"/> 185 <li>Click the <img src="{{static}}/images/gearsicon.png" width="29" height="23 " align="middle"/>
186 <strong>OAuth2.0 Configuration</strong> button in the top right corner.</li> 186 <strong>OAuth 2.0 Configuration</strong> button in the top right corner.</li>
187 <li>Check the box "Use your own OAuth credentials", 187 <li>Check the box "Use your own OAuth credentials",
188 enter the client ID and client secret, and click "Close".</li> 188 enter the client ID and client secret, and click "Close".</li>
189 <li>In the "Step 1" section, enter the scope 189 <li>In the "Step 1" section, enter the scope
190 <code>https://www.googleapis.com/auth/gcm_for_chrome</code> into the 190 <code>https://www.googleapis.com/auth/gcm_for_chrome</code> into the
191 "Input your own scopes" text box and click "Authorize APIs" button.</li> 191 "Input your own scopes" text box and click "Authorize APIs" button.</li>
192 <li>Assuming you are in Incognito mode, 192 <li>Assuming you are in Incognito mode,
193 you will be redirected to the Google login page. 193 you should be redirected to the Google log in page.
194 Login with the same Google Account that you will use to upload your app or ext ension 194 Login with the same Google Account that you will use to upload your app or ext ension
195 to the Chrome Web Store.</li> 195 to the Chrome Web Store.</li>
196 <li>After successful login, you will be redirected to a page to authorize the scopes. 196 <li>After successful log in, you are redirected to a page to authorize the sco pes.
197 Click "Allow access" button, redirecting you back to the OAuth 2.0 playground. </li> 197 Click "Allow access" button, redirecting you back to the OAuth 2.0 playground. </li>
198 <li>In "Step 2", click "Exchange authorization code for tokens" button.</li> 198 <li>In "Step 2", click "Exchange authorization code for tokens" button.</li>
199 </ol> 199 </ol>
200 200
201 <p> 201 <p>
202 The refresh token never expires until you explicitly revoke access. 202 The refresh token never expires until you explicitly revoke access.
203 You need to record and embed the refresh token in the app or extension server si de. 203 You need to record and embed the refresh token in the app or extension server si de.
204 </p> 204 </p>
205 205
206 <p class="caution"> 206 <p class="caution">
(...skipping 19 matching lines...) Expand all
226 "pushMessaging", 226 "pushMessaging",
227 ] 227 ]
228 </pre> 228 </pre>
229 229
230 <h3 id="channelid">Get channel ID</h2> 230 <h3 id="channelid">Get channel ID</h2>
231 231
232 <p> 232 <p>
233 Similar to an email address, 233 Similar to an email address,
234 the channel ID is used to identify and send messages 234 the channel ID is used to identify and send messages
235 to a specific user of your app or extension. 235 to a specific user of your app or extension.
236 Your app or extension will need to send this value 236 Your app or extension needs to send this value
237 to its application server so that the server 237 to its application server so that the server
238 can trigger push messages back. 238 can trigger push messages back.
239 To get the user's channel ID, 239 To get the user's channel ID,
240 call $ref:pushMessaging.getChannelId. 240 call $ref:pushMessaging.getChannelId.
241 Use the callback function 241 Use the callback function
242 to send the channel ID back to your app or extension. 242 to send the channel ID back to your app or extension.
243 </p> 243 </p>
244 244
245 <pre> 245 <pre>
246 chrome.pushMessaging.getChannelId(boolean interactive, function ChannelIdCallbac k) 246 chrome.pushMessaging.getChannelId(boolean interactive, function ChannelIdCallbac k)
247 </pre> 247 </pre>
248 248
249 <p> 249 <p>
250 When the <code>interactive</code> flag is set to true, 250 When the <code>interactive</code> flag is set to true,
251 the user is asked to log in if they haven't already done so 251 the user is asked to log in if they haven't already done so
252 with a warning dialog that looks something like this: 252 with a warning dialog that looks something like this:
253 "You must log into Chrome for the Calendar extension to receive push messages. 253 "You must log into Chrome for the Calendar extension to receive push messages.
254 Log in now?". 254 Log in now?"
255 </p> 255 </p>
256 256
257 <p> 257 <p>
258 To provide your users with a better experience, 258 To provide your users with a better experience,
259 the interactive flag should be set to false the first time 259 the interactive flag should be set to false the first time
260 your app or extension calls <code>getChannelId</code>. 260 your app or extension calls <code>getChannelId</code>.
261 Otherwise users will see the sign-in dialog 261 Otherwise users will see the sign-in dialog
262 with no context, 262 with no context,
263 even before they start your app or extension. 263 even before they start your app or extension.
264 If the first call fails because the user is not logged in, 264 If the first call fails because the user is not logged in,
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 {{/is_apps}} 319 {{/is_apps}}
320 320
321 <h2 id="five">Send messages</h2> 321 <h2 id="five">Send messages</h2>
322 322
323 <h3 id="access">Get new access token</h3> 323 <h3 id="access">Get new access token</h3>
324 324
325 <p> 325 <p>
326 You need a valid access token to push messages 326 You need a valid access token to push messages
327 to your app or extension. 327 to your app or extension.
328 To obtain a new access token, 328 To obtain a new access token,
329 make an HTTPS POST 329 make an <code>HTTPS POST</code>
330 that includes your client ID and refresh token. 330 that includes your client ID and refresh token.
331 <a href="https://developers.google.com/accounts/docs/OAuth2WebServer">Using OAut h 2.0 for 331 <a href="https://developers.google.com/accounts/docs/OAuth2WebServer">Using OAut h 2.0 for
332 Web Server Applications</a> 332 Web Server Applications</a>
333 describes this in greater detail. 333 describes this in greater detail.
334 A sample request would like something like this: 334 A sample request would like something like this:
335 </p> 335 </p>
336 336
337 <pre> 337 <pre>
338 POST /o/oauth2/token HTTP/1.1 338 POST /o/oauth2/token HTTP/1.1
339 Host: accounts.google.com 339 Host: accounts.google.com
(...skipping 22 matching lines...) Expand all
362 You should cache the access token for use 362 You should cache the access token for use
363 until it expires. 363 until it expires.
364 There is a rate limit on how often you can ask for access tokens. 364 There is a rate limit on how often you can ask for access tokens.
365 You may find yourself locked out of sending messages for awhile 365 You may find yourself locked out of sending messages for awhile
366 if you get a new access token every time you send a push message. 366 if you get a new access token every time you send a push message.
367 </p> 367 </p>
368 368
369 <h3 id="message">Send message to user</h3> 369 <h3 id="message">Send message to user</h3>
370 370
371 <p> 371 <p>
372 Send a POST body that includes the channel ID and subchannel ID 372 Send a <code>POST</code> body that includes the channel ID and subchannel ID
373 along with the message payload to the API endpoint 373 along with the message payload to the API endpoint
374 <code>https://www.googleapis.com/gcm_for_chrome/v1/messages</code>. 374 <code>https://www.googleapis.com/gcm_for_chrome/v1/messages</code>.
375 Here's what a sample HTTP call would look like: 375 Here's what a sample HTTP call would look like:
376 </p> 376 </p>
377 377
378 <pre> 378 <pre>
379 POST /gcm_for_chrome/v1/messages 379 POST /gcm_for_chrome/v1/messages
380 Host: www.googleapis.com 380 Host: www.googleapis.com
381 Content-Type: application/json 381 Content-Type: application/json
382 Authorization: Bearer 1/fFBGRNJru1FQd44AzqT3Zg 382 Authorization: Bearer 1/fFBGRNJru1FQd44AzqT3Zg
(...skipping 22 matching lines...) Expand all
405 405
406 <pre> 406 <pre>
407 function showPushMessage(message) { 407 function showPushMessage(message) {
408 var notification = window.webkitNotifications.createNotification( 408 var notification = window.webkitNotifications.createNotification(
409 '', 'New notification', message.payload + " [" + message.subchannelId + "]") ; 409 '', 'New notification', message.payload + " [" + message.subchannelId + "]") ;
410 notification.show(); 410 notification.show();
411 } 411 }
412 </pre> 412 </pre>
413 413
414 <p> 414 <p>
415 You will need to add the "notifications" permission 415 You need to add the "notifications" permission
416 to <code>manifest.json</code> 416 to <code>manifest.json</code>
417 to use text notifications 417 to use text notifications
418 (see <a href="notifications.html">Desktop Notifications</a>): 418 (see <a href="notifications.html">Desktop Notifications</a>):
419 </p> 419 </p>
420 420
421 <pre> 421 <pre>
422 "permissions": [ 422 "permissions": [
423 "pushMessaging", 423 "pushMessaging",
424 "notifications" 424 "notifications"
425 ] 425 ]
426 </pre> 426 </pre>
427 427
428 <h2 id="six">Error reference</h2> 428 <h2 id="six">Error reference</h2>
429 429
430 <p> 430 <p>
431 Push messaging error codes indicate whether the push request was accepted or rej ected. 431 Push messaging error codes indicate whether the push request was accepted or rej ected.
432 Rejection reasons range from sender errors (for example, malformed message), 432 Rejection reasons include sender errors (for example, malformed message),
433 permission errors (for example, revoked push messaging token), 433 permission errors (for example, revoked push messaging token),
434 and operational errors (for example, push messaging service is currently down). 434 and operational errors (for example, push messaging service is currently down).
435 </p> 435 </p>
436 436
437 <p> 437 <p>
438 Here's a brief summary of the push messaging errors: 438 Here's a brief summary of the push messaging errors:
439 </p> 439 </p>
440 440
441 <ul> 441 <ul>
442 <li>Channel Id is invalid.</li> 442 <li>Channel ID is invalid.</li>
443 <li>Subchannel is invalid (four subchannels available; 443 <li>Subchannel is invalid (four subchannels available;
444 subchannel value must be 0, 1, 2, or 3).</li> 444 subchannel value must be 0, 1, 2, or 3).</li>
445 <li>Payload is too long (must be 256 bytes or less).</li> 445 <li>Payload is too long (must be 256 bytes or less).</li>
446 <li>Daily message quota exceeded (10,000 message requests allowed per day).</l i> 446 <li>Daily message quota exceeded (10,000 message requests allowed per day).</l i>
447 <li>Google account calling the push messaging service does not own the app or extension.</li> 447 <li>Google Account calling the push messaging service does not own the app or extension.</li>
448 <li>App or extension is not whitelisted.</li> 448 <li>App or extension is not whitelisted.</li>
449 <li>An internal error has occurred. 449 <li>An internal error has occurred.
450 This indicates something went wrong on the Google server side 450 This indicates something went wrong on the Google server side
451 (for example, some backend not working 451 (for example, some backend not working
452 or errors in the HTTP post such as a missing access token).</li> 452 or errors in the HTTP post such as a missing access token).</li>
453 </ul> 453 </ul>
454 454
455 <h2 id="test">Testing</h3> 455 <h2 id="test">Testing</h3>
456 456
457 <p> 457 <p>
458 To test push messaging locally, 458 To test push messaging locally,
459 <a href="packaging.html">package</a> a test version of 459 <a href="packaging.html">package</a> a test version of
460 your app or extension on the Extensions management page 460 your app or extension on the Extensions management page
461 (go to <strong>chrome://extensions</strong> in your browser). 461 (go to <strong>chrome://extensions</strong> in your browser).
462 Your app or extension doesn't need to be running, just installed. 462 Your app or extension doesn't need to be running, just installed.
463 You will need to get the channel ID at install time 463 You need to get the channel ID at install time
464 using <a href="http://developer.chrome.com/apps/app.runtime.html#event-onLaunche d">app.runtime.onLaunched</a> (apps) or 464 using <a href="http://developer.chrome.com/apps/app.runtime.html#event-onLaunche d">app.runtime.onLaunched</a> (apps) or
465 <a href="http://developer.chrome.com/extensions/runtime.html#event-onInstalled"> runtime.onInstalled</a> (extensions). 465 <a href="http://developer.chrome.com/extensions/runtime.html#event-onInstalled"> runtime.onInstalled</a> (extensions).
466 Then, use that channel ID on the server to send a test 466 Then, use that channel ID on the server to send a test
467 push message through the system. 467 push message through the system.
468 All going well, 468 If all goes well,
469 your app or extension should start 469 your app or extension should start
470 and you should receive the test push message. 470 and you should receive the test push message.
471 </p> 471 </p>
472 472
473 <p> 473 <p>
474 To test push messaging works in the cloud, 474 To test that push messaging works in the cloud,
475 you need to publish to the Chrome Web Store first. 475 you need to publish to the Chrome Web Store first.
476 Once you have published, 476 Once you have published,
477 you need to copy the Chrome Web Store install key in the installed 477 you need to copy the Chrome Web Store install key in the installed
478 <code>manifest.json</code> to your source manifest 478 <code>manifest.json</code> to your source manifest
479 and then install a test version of your app or extension 479 and then install a test version of your app or extension
480 on the Extensions management page. 480 on the Extensions management page.
481 This ensures that you are testing the published version. 481 This ensures that you are testing the published version.
482 To get the key: 482 To get the key:
483 </p> 483 </p>
484 484
485 <ol> 485 <ol>
486 <li>Go to your 486 <li>Go to your
487 <a href="http://www.chromium.org/user-experience/user-data-directory">user dat a directory</a>. 487 <a href="http://www.chromium.org/user-experience/user-data-directory">user dat a directory</a>.
488 Example on MacOs: <code>~/Library/Application\ Support/Google/Chrome/Default/E xtensions</code></li> 488 Example on Mac OS X: <code>~/Library/Application\ Support/Google/Chrome/Defaul t/Extensions</code></li>
489 <li>Go to the installed extension directory with the appropriate Chrome Web St ore app ID. 489 <li>Go to the installed extension directory with the appropriate Chrome Web St ore app ID.
490 <li>Open the installed <code>manifest.json</code> 490 <li>Open the installed <code>manifest.json</code>
491 (pico is a quick way to open the file).</li> 491 (pico is a quick way to open the file).</li>
492 <li>Copy the "key" in the installed <code>manifest.json</code> and 492 <li>Copy the "key" in the installed <code>manifest.json</code> and
493 paste it into your app's source manifest file.</li> 493 paste it into your app's source manifest file.</li>
494 </ol> 494 </ol>
495 495
496 <p class="note"> 496 <p class="note">
497 The Chrome Web Store app ID is in the URL of any dashboard 497 The Chrome Web Store app ID is in the URL of any dashboard
498 or store page that's dedicated to your app or extension. 498 or store page that's dedicated to your app or extension.
499 For example, the URL 499 For example, the URL
500 <code>https://chrome.google.com/extensions/detail/aaaaaaaaaabbbbbbbbbbcccccccccc ?hl=en</code> 500 <code>https://chrome.google.com/extensions/detail/aaaaaaaaaabbbbbbbbbbcccccccccc ?hl=en</code>
501 has the app ID <code>aaaaaaaaaabbbbbbbbbbcccccccccc</code>. 501 has the app ID <code>aaaaaaaaaabbbbbbbbbbcccccccccc</code>.
502 </p> 502 </p>
503 503
504 <p> 504 <p>
505 Each time you reload your extension for testing, 505 Each time you reload your extension for testing,
506 you will need to check that the key is present. 506 you need to check that the key is present.
507 And anytime you wish to update the published version in the Chrome Web Store, 507 And anytime you wish to update the published version in the Chrome Web Store,
508 you will need to remove this key 508 you need to remove this key
509 because the store doesn't allow manifests with this key. 509 because the store doesn't allow manifests with this key.
510 </p> 510 </p>
OLDNEW
« no previous file with comments | « no previous file | chrome/common/extensions/docs/templates/articles/gcm_server.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698