DEV Community

Discussion on: Push Notifications in ReactJS with OneSignal

Collapse
 
ibengeu profile image
ibenge Uforo

Hey, thanks for this article. it was really helpful but ran into a problem.

How can we use this with a PWA having it's own service worker?

Collapse
 
devpato profile image
Pato

You can, you will have to change the scope of the service worker of OneSignal.-

something like this:

OneSignal.SERVICE_WORKER_PARAM = { scope: '/assets/js/' };
OneSignal.SERVICE_WORKER_PATH = '../assets/js/OneSignalSDKWorker.js';
OneSignal.SERVICE_WORKER_UPDATER_PATH = '../assets/js/OneSignalSDKUpdaterWorker.js';
Enter fullscreen mode Exit fullscreen mode
Collapse
 
nostin profile image
Sean Thompson

Hi Pato, thank you for this it is working really well but I don't understand this part. In mine the scope is set to /push/onesignal/... what is this doing?

Thread Thread
 
devpato profile image
Pato

Can you show me a screenshot of where you are seeing that, please? Thank you so much!

Collapse
 
ibengeu profile image
ibenge Uforo

I'm back again Pato, been on this for weeks.

At the moment, i'm getting "the script resource is behind a redirect which is disallowed" and have tried

  • switching positions of the folder from src to root ie. where React service worker files and it's registration is.
  • Placing the main files without the folder at the root.
  • changing scope url to an absolute path but to no avail.
  • Registering the oneSignal service worker file in place of reacts and using the importScript.

Please help.