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