Web/API/ServiceWorkerGlobalScope/push event

From Get docs


The 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.

Bubbles No
Cancelable No
Interface PushEvent
Event handler property onpush

Example

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);

Specifications

Specification Status Comment
Push APIThe definition of 'push' in that specification. Working Draft Initial specification.

Browser compatibility

Update compatibility data on GitHub

Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
push event Chrome

Full support 40

Edge

Full support ≤79

Firefox Full support 44

Notes'

Full support 44

Notes'

Notes' Extended Support Releases (ESR) before Firefox 78 ESR do not support service workers and the Push API.

IE

No support No

Opera

Full support 24

Safari

Full support 11.1

WebView Android

Full support 40

Chrome Android

Full support 40

Firefox Android

Full support 44

Opera Android

Full support 24

Safari iOS

Full support 11.3

Samsung Internet Android

Full support 4.0

Legend

Full support  
Full support
No support  
No support
See implementation notes.'
See implementation notes.


See also