Registering a custom Service Worker
Last updated
const registrationPromise = navigator.serviceWorker.register("/media/batchsdk-worker-loader.js");
batchSDK('setup', {
...,
// Service worker related configuration
serviceWorker: {
// Set it to `false` to prevent Batch from registering its own service worker
automaticallyRegister: false,
// A promise that resolves the service worker registration with your custom path
registration: registrationPromise
}
});
const subScopeRegistration = navigator.serviceWorker.register("batchsdk-worker-loader.js",
{ scope: "your_scope" });
batchSDK('setup', {
...,
// Service worker related configuration
serviceWorker: {
// Time Batch will wait for your service worker to be ready
waitTimeout: 10,
// Set it to `false` to prevent Batch from registering its own service worker
automaticallyRegister: false,
// A promise that resolves the service worker registration
registration: subScopeRegistration
}
});