BroadcastUpdatePlugin with Workbox

Hi, i’m trying to use the BroadcastUpdatePlugin to show a messagemodal, when a new appversion is available.

If i serve the app at localhost. all works as expected, but not at my firebasehosting.
For the firebasehosted version i expect, when I deploy a new appversion and reload the page, it should give me an updatemessage, but i don’t get it. After another reload, i see the new appversion, which then works as expected.

I created a small example with f7-cli:

Do someone have an idea whats wrong? I already have tried many different approaches in service-worker.js without success. I also moved the eventlistener on clientside to the init-function from F7, but that also doesn’t work.

I found a solution/workaround. I added skipWaiting(); to the service-worker.js file and changed the eventlistenerevent to 'controllerchange' in App.svelte.

It’s not a perfect solution, because skipWaiting has some drawbacks that haven’t time to study and understand at the moment and with this implementation i can’t send specific messages like ‘Hi, we have a themeupdate for you.’ or something like that. So it’s more a workaround, but it works :wink:

Hope this helps, if someone struggles with the same problem.

1 Like