fix push changes 3

This commit is contained in:
murdle 2025-12-21 16:26:35 +02:00
parent 6a1d9299f5
commit 51c9e38d12
2 changed files with 8 additions and 13 deletions

View File

@ -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();
}
}

View File

@ -96,6 +96,7 @@
await (checked ? registerPush(publicKey) : unregisterPush());
return true;
} catch(error) {
alert("Failed to register notifications: ", error.message)
return false;
}
}