ffdksgdpokg

This commit is contained in:
murdle 2025-12-21 16:29:23 +02:00
parent 51c9e38d12
commit ac6b282fdf

View File

@ -42,7 +42,7 @@ async function registerPush(publicKey) {
if (window.IS_IOS && !window.IS_STANDALONE) { if (window.IS_IOS && !window.IS_STANDALONE) {
throw new Error( throw new Error(
"On iOS, notifications require adding this site to the Home Screen." "On iOS, notifications require adding this site to the Home Screen"
); );
} }
@ -51,16 +51,14 @@ async function registerPush(publicKey) {
throw new Error("Notification permission not granted"); throw new Error("Notification permission not granted");
} }
const registration = await navigator.serviceWorker.register( const registration = await navigator.serviceWorker.register(
"/assets/custom/serviceWorker.js", "/assets/custom/serviceWorker.js"
{ scope: "/" } );
);
let subscription = await registration.pushManager.getSubscription(); let subscription = await registration.pushManager.getSubscription();
if (!subscription) { if (!subscription) {
const applicationServerKey = urlBase64ToUint8Array(publicKey); const applicationServerKey = urlBase64ToUint8Array(publicKey);
subscription = await registration.pushManager.subscribe({ subscription = await registration.pushManager.subscribe({
userVisibleOnly: true, userVisibleOnly: true,
applicationServerKey applicationServerKey
@ -84,6 +82,6 @@ async function registerPush(publicKey) {
if (!response.ok) { if (!response.ok) {
const text = await response.text(); const text = await response.text();
throw new Error(`Failed to register push: ${text}`); throw new Error(text);
} }
} }