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

View File

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