# Haravan + OneSignal - How to configure 2 service workers ## Requirements: We have to upload two file service workers in any subdirectory Examples: - https://maisononline.vn/apps/hrvsw/OneSignalSDKWorker.js?v=1594811926126 - https://maisononline.vn/apps/hrvsw/OneSignalSDKUpdaterWorker.js?v=1593143499086 We need to ensure there is the HTTP header: "Service-Worker-Allowed : /" when you get the files You can check the Header like below using Chrome Network Tool ![](https://i.imgur.com/QnmUzvk.png) ## Setup in OneSignal Dashboard We **must** choose <b>Typical setup</b> ![](https://i.imgur.com/yHR1LGD.png) Go to Advanced section ![](https://i.imgur.com/egLHtVV.png) 1) Path service worker files This is the directory of the service workers 2) Main service worker filename This is the name of the service file Value: ```OneSignalSDKWorker.js?v=1594811926126``` 3) Updater service worker filename This is the name of the service updater file Value: ```OneSignalSDKUpdaterWorker.js?v=1593143499086``` 4) Service worker registration scope This is the most important thing!, decide where we can register our service worer Value: ```/``` Root mean at we can always register the sw at all pages However, this requires Haravan to setup the HTTP header ```"Service-Worker-Allowed : /"``` when in the response when we get the files before. Below is the sample code of Maison ```html <script src="https://cdn.onesignal.com/sdks/OneSignalSDK.js" async=""></script> <script> window.OneSignal = window.OneSignal || []; var initConfig = { appId: "8b9d04ed-04cf-41a0-a3ab-81c8e16e896b", notifyButton: { enable: true }, path: '/apps/hrvsw/' }; OneSignal.push(function () { // This registers the workers at the root scope, which is allowed by the HTTP header "Service-Worker-Allowed: /" OneSignal.SERVICE_WORKER_PARAM = { scope: '/' }; OneSignal.SERVICE_WORKER_PATH = 'apps/hrvsw/OneSignalSDKWorker.js?v=1594811926126' OneSignal.SERVICE_WORKER_UPDATER_PATH = 'apps/hrvsw/OneSignalSDKUpdaterWorker.js?v=1593143499086' OneSignal.init(initConfig); }); </script> ``` References: https://documentation.onesignal.com/docs/onesignal-service-worker-faq https://documentation.onesignal.com/docs/web-push-custom-code-examples#section-initialization Additional Steps: Delete users if reach more than 100 users https://documentation.onesignal.com/docs/delete-users