Can't put onesignal service worker js files in root in github

Viewed 387

I have used github-pages to publish my site. I'm trying to use onesignal there. But I can't store the sdk files in the root. I'm getting this console error.

Installing service worker failed TypeError: Failed to register a ServiceWorker for scope ('https://username.github.io/') with script ('https://username.github.io/OneSignalSDKWorker.js?appId=<MY_APP_ID>'): A bad HTTP response code (404) was received when fetching the script.

1 Answers

A 404 means the service worker script is not where the SDK thinks it is. Try visiting the URL in your browser (https://username.github.io/OneSignalSDKWorker.js). You should see the script there. If it is not there, you have not successfully hosted the required file.

Related