Closed debbyji17 closed 2 years ago
Hi @debbyji17 can you try using the serviceWorkerLocation: "/sw.js"
initialization option? https://js.appboycdn.com/web-sdk/latest/doc/modules/braze.html#initializationoptions
Hi @davidbielik
Yes, it works! Thanks for your quickly reply. :)
Is it a new change in v4? Because it works in v3 without serviceWorkerLocation
options needed.
Hi @debbyji17 you're welcome!
No, this isn't a new change so you should have the same behavior on v2 or v3.
Braze Web SDK Version
~4.0.2
Integration Method
CDN
Browser
Chrome
Steps To Reproduce
Here's our own service worker file, we added
self.importScripts('https://js.appboycdn.com/web-sdk/4.0/service-worker.js');
at the bottom of the file./src/app/service-worker.js
We use
workbox-webpack-plugin
this plugin to build our service worker file, the build file will generatesw.js
at root.webpack.config.js
Expected Behavior
When I push notification in Braze dashboard, it should be sent successfully, and test user should be receive the notifications.
Actual Incorrect Behavior
When I push notification in Braze dashboard, it shows error popup,
console throw the error message below, because we didn't have service-worker.js in our root. Our service worker file name is
sw.js
.We found that if we changed build file name from
sw.js
toservice-worker.js
, it can work and don't have any error message. Butsw.js
file can work on v3.x, and there is no error message. So we just wonder that why we couldn't usesw.js
as our service worker build file name.Verbose Logs
No response
Additional Information
No response