OneSignal / onesignal-vue3

Vue 3 OneSignal Plugin: Make it easy to integrate OneSignal with your Vue App!
Other
19 stars 5 forks source link

serviceWorkerParam, serviceWorkerPath are ignored #1

Closed this1-it closed 2 years ago

this1-it commented 2 years ago

I need to change scope of onesignal service worker because my pwa has already a service-worker

app.use(OneSignalVuePlugin, { appId, safari_web_id: "", notifyButton: { enable: true, }, serviceWorkerParam: { scope: "/onesignal/" }, serviceWorkerPath: 'onesignal/OneSignalSDKWorker.js' })

It is the right way ?

I have modified init configuration and placed OneSignalSDKWorker.js in onesignal folder under root Onesignal service worker is not loaded and error in browser indicates file is searched in root folder instead of serviceWorkerPath

Uncaught (in promise) DOMException: Failed to register a ServiceWorker for scope ('https://pwa-example.com/') with script ('https://pwa-example.com/OneSignalSDKWorker.js

of course if I put OneSignalSDKWorker.js at root, there are not errors but service-worker cannot start because of pwa service worker

jkasten2 commented 2 years ago

@this1-it Did you use "Typical Site Setup" on the OneSignal dashboard, if so you may need to set these params on the dashboard instead of in code: https://documentation.onesignal.com/docs/onesignal-service-worker-faq#typical-site-setup---service-worker-customizations

this1-it commented 2 years ago

Thank you very much, it's all clear now ! I thought options parameters worked without any setup on dashboard.

jkasten2 commented 2 years ago

@this1-it Good to hear! The code params may only work if you selected "Custom Code Setup" instead of "Typical Site Setup" on the OneSignal dashboard.