Claim client on Service worker Activation



Why doesn’t clevertap claim my hostname as client for scope as my default service worker does…?

Arbaaz Dossani


@Arbaaz_Dossani1 Can you please elaborate a bit?


Hi Apurva,

Thanks for your prompt response.

I am facing an issue where I want to integrate clevertap service-worker with my custom-service-worker before it requests for user notification permission (with the pop-up).

After the user allows notification request, Clevertap will again register its service-worker but its scope is not defined for my particular website, i.e. it does not claim my hostname as client, which is essential for offline plugins like sw-toolbox, etc



when you have to include two service worker files:

  1. Request you to import CleverTap’s server worker in your service worker file. importScripts(‘’);

  2. When asking for notification permission, you have to add an additional key-value pair to specify your serviceWorkerPath.

“okButtonColor”:okButtonColorInHex, “serviceWorkerPath”:“/your-serviceworker.js”});

This should work for you!


Hi Apurva,

I need to include only one service worker.
The above is my current implementation. However when user accepts notification permission, it re-registers the service worker again, but without scope and therefore does not work when user is offline.

Please help!


Hello apurva
service worker file… can we set service-worker.js file in my project root folder ya where to put.
actually i an confuse about that where to add this file


Hey Amar,

You have to upload the service worker file to your root directory to make this work.