window.OneSignalDeferred = window.OneSignalDeferred || []; OneSignalDeferred.push(async function(OneSignal) { await OneSignal.init({ appId: "337a5be0-b832-45c6-a33a-0102e29d003d", serviceWorkerOverrideForTypical: true, path: "https://www.magzlifenews.com/wp-content/plugins/onesignal-free-web-push-notifications/sdk_files/", serviceWorkerParam: { scope: "/wp-content/plugins/onesignal-free-web-push-notifications/sdk_files/push/onesignal/" }, serviceWorkerPath: "OneSignalSDKWorker.js", }); }); // Unregister the legacy OneSignal service worker to prevent scope conflicts navigator.serviceWorker.getRegistrations().then((registrations) => { // Iterate through all registered service workers registrations.forEach((registration) => { // Check the script URL to identify the specific service worker if (registration.active && registration.active.scriptURL.includes('OneSignalSDKWorker.js.php')) { // Unregister the service worker registration.unregister().then((success) => { if (success) { console.log('OneSignalSW: Successfully unregistered:', registration.active.scriptURL); } else { console.log('OneSignalSW: Failed to unregister:', registration.active.scriptURL); } }); } }); }).catch((error) => { console.error('Error fetching service worker registrations:', error); });