如何处理Push Notifications服务工作人员中的PushSubScriptionChange事件?
我们如何更新Chrome中的订阅?截至今天,Chrome不听PushNotificationChange事件。因此,下面的代码在Chrome的情况下不起作用。
从:
self.addEventListener('pushsubscriptionchange', function(event) {
event.waitUntil(
fetch('https://pushpad.xyz/pushsubscriptionchange', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
old_endpoint: event.oldSubscription ? event.oldSubscription.endpoint : null,
new_endpoint: event.newSubscription ? event.newSubscription.endpoint : null,
new_p256dh: event.newSubscription ? event.newSubscription.toJSON().keys.p256dh : null,
new_auth: event.newSubscription ? event.newSubscription.toJSON().keys.auth : null
})
})
);
});
” : https://bugs.chromium.chromium.orgs.org/p/chromium/sissues/sissues/sissues /细节?id = 753163
How can we update subscription in chrome? As of today chrome does not listen to pushnotificationchange event. So code below will not work in case of chrome.
code taken from: https://pushpad.xyz/service-worker.js
self.addEventListener('pushsubscriptionchange', function(event) {
event.waitUntil(
fetch('https://pushpad.xyz/pushsubscriptionchange', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
old_endpoint: event.oldSubscription ? event.oldSubscription.endpoint : null,
new_endpoint: event.newSubscription ? event.newSubscription.endpoint : null,
new_p256dh: event.newSubscription ? event.newSubscription.toJSON().keys.p256dh : null,
new_auth: event.newSubscription ? event.newSubscription.toJSON().keys.auth : null
})
})
);
});
Chrome issue link: https://bugs.chromium.org/p/chromium/issues/detail?id=753163
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论