Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

ServiceWorkerGlobalScope.onpushsubscriptionchange

我们的志愿者还没有将这篇文章翻译为 中文 (简体)加入我们帮助完成翻译!

This is an experimental technology
Because this technology's specification has not stabilized, check the compatibility table for usage in various browsers. Also note that the syntax and behavior of an experimental technology is subject to change in future versions of browsers as the specification changes.

The ServiceWorkerGlobalScope.onpushsubscriptionchange event of the ServiceWorkerGlobalScope interface 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

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari (WebKit)
Basic support No support 44.0 (44.0)[1] No support ? No support
Feature Android Android Webview Firefox Mobile (Gecko) Firefox OS IE Mobile Opera Mobile Safari Mobile Chrome for Android
Basic support No support No support 44.0 (44.0) (Yes) No support ? No support No support

[1] Service workers (and Push) have been disabled in the Firefox 45 Extended Support Release (ESR.)

See also

文档标签和贡献者

 此页面的贡献者: chrisdavidmills, jpmedley, Sebastianz, Sheppy
 最后编辑者: chrisdavidmills,