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 API The 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
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
onpushsubscriptionchange | Chrome Full support 40 | Edge Full support ≤79 | Firefox
Full support
44
| 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.