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.
ServiceWorkerGlobalScope.onpushsubscriptionchange = function() { ... }
self.addEventListener('pushsubscriptionchange', function() { ... })
self.addEventListener('pushsubscriptionchange', function() {
// do something, usually resubscribe to push and
// send the new subscription details back to the
// server via XHR or Fetch
});
| 规范 | 状态 | 注释 |
|---|---|---|
|
Push API
The definition of 'onpushsubscriptionchange' in that specification. |
工作草案 |
Initial definition (Note: This event is specified in the Push API, but accessed through
ServiceWorkerGlobalScope
)。
|
| 桌面 | 移动 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
onpushsubscriptionchange
|
Chrome 40 | Edge ≤79 |
Firefox
44
注意事项
|
IE 不支持 No | Opera 24 | Safari 11.1 | WebView Android 40 | Chrome Android 40 | Firefox Android 44 | Opera Android 24 | Safari iOS 11.3 | Samsung Internet Android 4.0 |
完整支持
不支持
实验。期望将来行为有所改变。
见实现注意事项。
ServiceWorkerGlobalScope
caches
clients
onactivate
onfetch
oninstall
onmessage
onnotificationclick
onnotificationclose
onpush
onpushsubscriptionchange
registration