ServiceWorkerGlobalScope.onpushsubscriptionchange - Web APIs 编辑
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
BCD tables only load in the browser
See also
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论