|
59 | 59 | <body data-cite="service-workers FILEAPI">
|
60 | 60 | <section id="abstract">
|
61 | 61 | <p>
|
62 |
| - The <cite>Push API</cite> enables sending of a <a>push message</a> to a <a>webapp</a> via a |
63 |
| - <a>push service</a>. An <a>application server</a> can send a <a>push message</a> at any |
64 |
| - time, even when a <a>webapp</a> or <a>user agent</a> is inactive. The <a>push service</a> |
| 62 | + The <cite>Push API</cite> enables sending of a <a>push message</a> to a web application via |
| 63 | + a <a>push service</a>. An <a>application server</a> can send a <a>push message</a> at any |
| 64 | + time, even when a web application or <a>user agent</a> is inactive. The <a>push service</a> |
65 | 65 | ensures reliable and efficient delivery to the <a>user agent</a>. <a>Push messages</a> are
|
66 |
| - delivered to a <a>Service Worker</a> that runs in the origin of the <a>webapp</a>, which |
| 66 | + delivered to a <a>Service Worker</a> that runs in the origin of the web application, which |
67 | 67 | can use the information in the message to update local state or display a notification to
|
68 | 68 | the user.
|
69 | 69 | </p>
|
|
78 | 78 | Introduction
|
79 | 79 | </h2>
|
80 | 80 | <p>
|
81 |
| - The Push API allows a <a>webapp</a> to communicate with a <a>user agent</a> asynchronously. |
82 |
| - This allows an <a>application server</a> to provide the <a>user agent</a> with |
83 |
| - time-sensitive information whenever that information becomes known, rather than waiting for |
84 |
| - a user to open the <a>webapp</a>. |
| 81 | + The Push API allows a web application to communicate with a <a>user agent</a> |
| 82 | + asynchronously. This allows an <a>application server</a> to provide the <a>user agent</a> |
| 83 | + with time-sensitive information whenever that information becomes known, rather than |
| 84 | + waiting for a user to open the web application. |
85 | 85 | </p>
|
86 | 86 | <p>
|
87 | 87 | As defined here, <a>push services</a> support delivery of <a>push messages</a> at any time.
|
88 | 88 | </p>
|
89 | 89 | <p>
|
90 |
| - In particular, a <a>push message</a> will be delivered to the <a>webapp</a> even if that |
91 |
| - <a>webapp</a> is not currently active in a browser window: this relates to use cases in |
92 |
| - which the user may close the <a>webapp</a>, but still benefits from the <a>webapp</a> being |
93 |
| - able to be restarted when a <a>push message</a> is received. For example, a <a>push |
| 90 | + In particular, a <a>push message</a> will be delivered to the web application even if that |
| 91 | + web application is not currently active in a browser window: this relates to use cases in |
| 92 | + which the user may close the web application, but still benefits from the web application |
| 93 | + being able to be restarted when a <a>push message</a> is received. For example, a <a>push |
94 | 94 | message</a> might be used to inform the user of an incoming WebRTC call.
|
95 | 95 | </p>
|
96 | 96 | <p>
|
97 | 97 | A <a>push message</a> can also be sent when the <a>user agent</a> is temporarily offline.
|
98 | 98 | In support of this, the <a>push service</a> stores messages for the <a>user agent</a> until
|
99 |
| - the <a>user agent</a> becomes available. This supports use cases where a <a>webapp</a> |
| 99 | + the <a>user agent</a> becomes available. This supports use cases where a web application |
100 | 100 | learns of changes that occur while a user is offline and ensures that the <a>user agent</a>
|
101 | 101 | can be provided with relevant information in a timely fashion. <a>Push messages</a> are
|
102 | 102 | stored by the <a>push service</a> until the <a>user agent</a> becomes reachable and the
|
103 | 103 | message can be delivered.
|
104 | 104 | </p>
|
105 | 105 | <p>
|
106 | 106 | The Push API will also ensure reliable delivery of push messages while a <a>user agent</a>
|
107 |
| - is actively using a <a>webapp</a>, for instance if a user is actively using the |
108 |
| - <a>webapp</a> or the <a>webapp</a> is in active communication with an <a>application |
| 107 | + is actively using a web application, for instance if a user is actively using the web |
| 108 | + application or the web application is in active communication with an <a>application |
109 | 109 | server</a> through an active worker, frame, or background window. This is not the primary
|
110 |
| - use case for the Push API. A <a>webapp</a> might choose to use the Push API for infrequent |
111 |
| - messages to avoid having to maintain constant communications with the <a>application |
112 |
| - server</a>. |
| 110 | + use case for the Push API. A web application might choose to use the Push API for |
| 111 | + infrequent messages to avoid having to maintain constant communications with the |
| 112 | + <a>application server</a>. |
113 | 113 | </p>
|
114 | 114 | <p>
|
115 | 115 | Push messaging is best suited to occasions where there is not already an active
|
116 |
| - communications channel established between <a>user agent</a> and <a>webapp</a>. Sending |
| 116 | + communications channel established between <a>user agent</a> and web application. Sending |
117 | 117 | <a>push messages</a> requires considerably more resources when compared with more direct
|
118 | 118 | methods of communication such as [[[fetch]]] or <a data-cite=
|
119 | 119 | "html/web-sockets.html#network">websockets</a>. <a>Push messages</a> usually have higher
|
@@ -150,24 +150,19 @@ <h2>
|
150 | 150 | </h2>
|
151 | 151 | <section>
|
152 | 152 | <h2>
|
153 |
| - Webapp |
| 153 | + Application server |
154 | 154 | </h2>
|
155 | 155 | <p>
|
156 |
| - The term <dfn>webapp</dfn> refers to a Web application, i.e. an application implemented |
157 |
| - using Web technologies, and executing within the context of a Web <a>user agent</a>, e.g. |
158 |
| - a Web browser or other Web runtime environment. |
159 |
| - </p> |
160 |
| - <p> |
161 |
| - The term <dfn>application server</dfn> refers to server-side components of a |
162 |
| - <a>webapp</a>. |
| 156 | + The term <dfn>application server</dfn> refers to server-side components of a web |
| 157 | + application. |
163 | 158 | </p>
|
164 | 159 | </section>
|
165 | 160 | <section>
|
166 | 161 | <h2>
|
167 | 162 | Push message
|
168 | 163 | </h2>
|
169 | 164 | <p>
|
170 |
| - A <dfn>push message</dfn> is data sent to a <a>webapp</a> from an <a>application |
| 165 | + A <dfn>push message</dfn> is data sent to a web application from an <a>application |
171 | 166 | server</a>.
|
172 | 167 | </p>
|
173 | 168 | <p>
|
|
182 | 177 | </h2>
|
183 | 178 | <p>
|
184 | 179 | A <dfn>push subscription</dfn> is a message delivery context established between the
|
185 |
| - <a>user agent</a> and the <a>push service</a> on behalf of a <a>webapp</a>. Each <a>push |
186 |
| - subscription</a> is associated with a <a>service worker registration</a> and a <a>service |
187 |
| - worker registration</a> has at most one <a>push subscription</a>. |
| 180 | + <a>user agent</a> and the <a>push service</a> on behalf of a web application. Each |
| 181 | + <a>push subscription</a> is associated with a <a>service worker registration</a> and a |
| 182 | + <a>service worker registration</a> has at most one <a>push subscription</a>. |
188 | 183 | </p>
|
189 | 184 | <p>
|
190 | 185 | A <a>push subscription</a> has an associated <dfn>push endpoint</dfn>. It MUST be the
|
|
303 | 298 | </h2>
|
304 | 299 | <p>
|
305 | 300 | The term <dfn data-lt="push services">push service</dfn> refers to a system that allows
|
306 |
| - <a>application servers</a> to send <a>push messages</a> to a <a>webapp</a>. A push |
| 301 | + <a>application servers</a> to send <a>push messages</a> to a web application. A push |
307 | 302 | service serves the <a>push endpoint</a> or <a data-lt="push endpoints">endpoints</a> for
|
308 | 303 | the <a>push subscriptions</a> it serves.
|
309 | 304 | </p>
|
|
323 | 318 | <p>
|
324 | 319 | The term <dfn>express permission</dfn> refers to an act by the user, e.g. via user
|
325 | 320 | interface or host device platform features, via which the user approves the use of the
|
326 |
| - Push API by the <a>webapp</a>. |
| 321 | + Push API by the web application. |
327 | 322 | </p>
|
328 | 323 | </section>
|
329 | 324 | </section>
|
|
341 | 336 | </p>
|
342 | 337 | <p>
|
343 | 338 | There is no guarantee that a <a>push message</a> was sent by an <a>application server</a>
|
344 |
| - having the same origin as the <a>webapp</a>. The <a>application server</a> is able to share |
345 |
| - the details necessary to use a <a>push subscription</a> with a third party at its own |
| 339 | + having the same origin as the web application. The <a>application server</a> is able to |
| 340 | + share the details necessary to use a <a>push subscription</a> with a third party at its own |
346 | 341 | discretion.
|
347 | 342 | </p>
|
348 | 343 | <p>
|
|
361 | 356 | The Push API may have to wake up the Service Worker associated with the <a>service worker
|
362 | 357 | registration</a> in order to run the developer-provided event handlers. This can cause
|
363 | 358 | resource usage, such as network traffic, that the <a>user agent</a> SHOULD attribute to the
|
364 |
| - <a>webapp</a> that created the <a>push subscription</a>. |
| 359 | + web application that created the <a>push subscription</a>. |
365 | 360 | </p>
|
366 | 361 | <p>
|
367 | 362 | The <a>user agent</a> MAY consider the <a>PushSubscriptionOptions</a> when acquiring
|
|
402 | 397 | Push Framework
|
403 | 398 | </h2>
|
404 | 399 | <p>
|
405 |
| - A <a>push message</a> is sent from an <a>application server</a> to a <a>webapp</a> as |
| 400 | + A <a>push message</a> is sent from an <a>application server</a> to a web application as |
406 | 401 | follows:
|
407 | 402 | </p>
|
408 | 403 | <ul>
|
|
420 | 415 | <p>
|
421 | 416 | This overall framework allows <a>application servers</a> to activate a <a>Service
|
422 | 417 | Worker</a> in response to events at the <a>application server</a>. Information about those
|
423 |
| - events can be included in the <a>push message</a>, which allows the <a>webapp</a> to react |
424 |
| - appropriately to those events, potentially without needing to initiate network requests. |
| 418 | + events can be included in the <a>push message</a>, which allows the web application to |
| 419 | + react appropriately to those events, potentially without needing to initiate network |
| 420 | + requests. |
425 | 421 | </p>
|
426 | 422 | <p>
|
427 | 423 | The following code and diagram illustrate a hypothetical use of the push API.
|
|
485 | 481 | <ul>
|
486 | 482 | <li>The <a data-lt="PushSubscription.endpoint">push endpoint</a> of a
|
487 | 483 | <a>PushSubscription</a> is a URL that allows an <a>application server</a> to request
|
488 |
| - delivery of a <a>push message</a> to a <a>webapp</a>. |
| 484 | + delivery of a <a>push message</a> to a web application. |
489 | 485 | </li>
|
490 | 486 | <li data-link-for="PushSubscription">The {{getKey()}} method on a <a>PushSubscription</a>
|
491 | 487 | is used to retrieve keying material used to encrypt and authenticate <a>push
|
|
591 | 587 | <li>If <var>registration</var>'s <a>active worker</a> is null, reject <var>promise</var>
|
592 | 588 | with a {{DOMException}} whose name is "{{InvalidStateError}}" and terminate these steps.
|
593 | 589 | </li>
|
594 |
| - <li>Ask the user whether they allow the <a>webapp</a> to receive <a>push messages</a>, |
| 590 | + <li>Ask the user whether they allow the web application to receive <a>push messages</a>, |
595 | 591 | unless a prearranged trust relationship applies or the user has already granted or denied
|
596 |
| - permission explicitly for this <a>webapp</a>. Note that a <a>user agent</a> that needs to |
| 592 | + permission explicitly for this web application. Note that a <a>user agent</a> that needs to |
597 | 593 | request permission might be unable to do so if <a data-link-for="PushManager">subscribe</a>
|
598 | 594 | is invoked from a service worker, in which case permission will be denied automatically.
|
599 | 595 | </li>
|
|
927 | 923 | <dfn>PushEncryptionKeyName</dfn> enumeration
|
928 | 924 | </h2>
|
929 | 925 | <p>
|
930 |
| - Encryption keys used for <a>push message</a> encryption are provided to a <a>webapp</a> |
| 926 | + Encryption keys used for <a>push message</a> encryption are provided to a web application |
931 | 927 | through the <a data-link-for="PushSubscription">getKey</a> method or the serializer of
|
932 | 928 | <a>PushSubscription</a>. Each key is named using a value from the
|
933 | 929 | <a>PushEncryptionKeyName</a> enumeration.
|
@@ -1250,7 +1246,7 @@ <h2>
|
1250 | 1246 | The <dfn>newSubscription</dfn> member details the <a>push subscription</a> that is
|
1251 | 1247 | valid per invocation of the <a>pushsubscriptionchange</a> event. The value will be
|
1252 | 1248 | `null` when no new <a>push subscription</a> could be established, for example because
|
1253 |
| - the <a>webapp</a> has lost <a>express permission</a>. |
| 1249 | + the web application has lost <a>express permission</a>. |
1254 | 1250 | </p>
|
1255 | 1251 | <p>
|
1256 | 1252 | The <dfn>oldSubscription</dfn> member details the <a>push subscription</a> that SHOULD
|
@@ -1285,23 +1281,23 @@ <h2>
|
1285 | 1281 | <dfn>granted</dfn>
|
1286 | 1282 | </td>
|
1287 | 1283 | <td>
|
1288 |
| - The <a>webapp</a> has permission to use the Push API. |
| 1284 | + The web application has permission to use the Push API. |
1289 | 1285 | </td>
|
1290 | 1286 | </tr>
|
1291 | 1287 | <tr>
|
1292 | 1288 | <td>
|
1293 | 1289 | <dfn>denied</dfn>
|
1294 | 1290 | </td>
|
1295 | 1291 | <td>
|
1296 |
| - The <a>webapp</a> has been denied permission to use the Push API. |
| 1292 | + The web application has been denied permission to use the Push API. |
1297 | 1293 | </td>
|
1298 | 1294 | </tr>
|
1299 | 1295 | <tr>
|
1300 | 1296 | <td>
|
1301 | 1297 | <dfn>prompt</dfn>
|
1302 | 1298 | </td>
|
1303 | 1299 | <td>
|
1304 |
| - The <a>webapp</a> needs to ask for permission in order to use the Push API. |
| 1300 | + The web application needs to ask for permission in order to use the Push API. |
1305 | 1301 | </td>
|
1306 | 1302 | </tr>
|
1307 | 1303 | </table>
|
|
0 commit comments