DEV Community

Discussion on: How To Create A PWA With JavaScript

Collapse
 
mma15 profile image
Mubashir Ali Mir • Edited

Hi Pato!! Thank you for tutorial its really helpful. There was one thing I was wondering , how do we combine the sw.js you created for the Add to Home Screen PWA to the firebase push notifications one. Currently, both my service workers are overwriting each other so only one of them works.

Just to clarify, I am registering both service workers in main.js, one after each other.

Collapse
 
devpato profile image
Pato

You can only have one service worker (besides the firebase-messaging-sw.js). In this code I have that functionality combined together github.com/devpato/creating-a-pwa-...

Collapse
 
mma15 profile image
Mubashir Ali Mir

Thank you for the quick response! So just to confirm, with this, the sw.js is able to function properly and firebase is still able to talk to the background app without us registering it on our side?

Thread Thread
 
devpato profile image
Pato

you will have the firebase-messaging-sw.js and the sw.js file like I did on the repo. Make sure the firebase-messaging-sw.js has that name. That's how firebase code will look for that file