我正在Chrome的网络应用程序中实现推送通知。以前,以下代码在Firefox中运行良好。但是在更新Firefox之后,我遇到了异常。
function subscribeUser() {
const applicationServerKey =
urlB64ToUint8Array(applicationServerPublicKey);
swRegistration.pushManager.subscribe({
userVisibleOnly: true,
applicationServerKey: applicationServerKey
})
.then(function(subscription) {
console.log('User is subscribed.');
updateSubscriptionOnServer(subscription);
isSubscribed = true;
updateBtn();
})
.catch(function(err) {
console.log('Failed to subscribe the user: ', err);
updateBtn();
});
}
DOMException:“检索推送订阅时出错。”