Web/API/ServiceWorkerGlobalScope/onpushsubscriptionchange

From Get docs


The ServiceWorkerGlobalScope.onpushsubscriptionchange event of the ServiceWorkerGlobalScope interface is fired to indicate a change in push subscription that was triggered outside the application's control, e.g. when browser refresh the push subscription.

Previously, it was defined as the event interface that is fired whenever a push subscription has been invalidated (or is about to become so). This offers an opportunity to resubscribe in order to continue receiving push messages, if desired. This might happen if, for example, the push service sets an expiration time a subscription.

Syntax

ServiceWorkerGlobalScope.onpushsubscriptionchange = function() { ... }
self.addEventListener('pushsubscriptionchange', function() { ... })

Example

self.addEventListener('pushsubscriptionchange', function() {
  // do something, usually resubscribe to push and
  // send the new subscription details back to the
  // server via XHR or Fetch
});

Specifications

Specification Status Comment
Push APIThe definition of 'onpushsubscriptionchange' in that specification. Working Draft Initial definition (Note: This event is specified in the Push API, but accessed through ServiceWorkerGlobalScope.)

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

onpushsubscriptionchange

Experimental'

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
Experimental. Expect behavior to change in the future.'
Experimental. Expect behavior to change in the future.
See implementation notes.'
See implementation notes.


See also