ServiceWorkerGlobalScope: push event

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 API
The definition of 'push' in that specification.
Working Draft Initial specification.

Browser compatibility

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidEdge MobileFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
push eventChrome Full support 40Edge ? Firefox Full support 44
Notes
Full support 44
Notes
Notes Service workers (and Push) have been disabled in the Firefox 45 and 52 Extended Support Releases (ESR).
IE No support NoOpera Full support 24Safari Full support 11.1WebView Android Full support 40Chrome Android Full support 40Edge Mobile ? Firefox Android Full support 44Opera Android Full support 24Safari iOS Full support 11.1Samsung Internet Android Full support 4.0

Legend

Full support  
Full support
No support  
No support
Compatibility unknown  
Compatibility unknown
See implementation notes.
See implementation notes.

See also

Document Tags and Contributors

Contributors to this page: wbamberg, Sheppy, mdnwebdocs-bot, jrconlin, chrisdavidmills
Last updated by: wbamberg,