How to migrate multiple websites into Batch Omnichannel projects?
Case A: Independent websites
Case B: Variants of the same website
3
JavaScript tag implementation
async function replaceBatchRegistrations() {
if (!("serviceWorker" in navigator)) {
return;
}
// List registered service workers
const currentServiceWorkerRegistrations = await navigator.serviceWorker.getRegistrations();
await currentServiceWorkerRegistrations.forEach( async (registration) => {
if (registration.scope === 'https://www.domain.fr/') { //REPLACE WITH OLD SCOPE
// Found old service worker -> Removing
console.debug("Found old service worker -> Removing")
await registration.unregister()
} else if (registration.scope === 'https://www.domain.fr/js/') { //REPLACE WITH NEW SCOPE
if (!("pushManager" in registration)) {
return;
}
}
})
}
await replaceBatchRegistrations()Last updated




