push
event is sent to a service worker's global scope (represented by the
ServiceWorkerGlobalScope
interface) when the service worker has received a push message.
| 冒泡 | No |
|---|---|
| 可取消 | No |
| 接口 |
PushEvent
|
| 事件处理程序特性 |
onpush
|
This example sets up a handler for
push
events that takes
JSON
data, parses it, and dispatches the message for handling based on information contained within the message.
self.addEventListener("push", event => {
let message = event.data.json();
switch(message.type) {
case "init":
doInit();
break;
case "shutdown":
doShutdown();
break;
}
}, false);
| 规范 | 状态 | 注释 |
|---|---|---|
|
Push API
The definition of 'push' in that specification. |
工作草案 | 最初的规范。 |
| 桌面 | 移动 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
push
event
|
Chrome 40 | Edge ≤79 |
Firefox
44
|
IE No | Opera 24 | Safari 11.1 | WebView Android 40 | Chrome Android 40 | Firefox Android 44 | Opera Android 24 | Safari iOS 11.3 | Samsung Internet Android 4.0 |
完整支持
不支持
见实现注意事项。
onpush
event handler property
pushsubscriptionchange
event