fix push changes 3
This commit is contained in:
parent
6a1d9299f5
commit
51c9e38d12
@ -26,20 +26,14 @@ async function isPushRegistered() {
|
||||
|
||||
async function unregisterPush() {
|
||||
checkServiceWorkerSupport();
|
||||
try {
|
||||
const reg = await navigator.serviceWorker.ready;
|
||||
const sub = await reg.pushManager.getSubscription();
|
||||
const reg = await navigator.serviceWorker.ready;
|
||||
const sub = await reg.pushManager.getSubscription();
|
||||
|
||||
if (sub) {
|
||||
await sub.unsubscribe();
|
||||
}
|
||||
|
||||
if (!window.isIOS()) {
|
||||
await reg.unregister();
|
||||
}
|
||||
} catch (err) {
|
||||
alert("Failed to unregister push");
|
||||
console.error(err);
|
||||
if (sub) {
|
||||
await sub.unsubscribe();
|
||||
}
|
||||
if (!window.IS_IOS) {
|
||||
await reg.unregister();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -96,6 +96,7 @@
|
||||
await (checked ? registerPush(publicKey) : unregisterPush());
|
||||
return true;
|
||||
} catch(error) {
|
||||
alert("Failed to register notifications: ", error.message)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user