Closed lilfolr closed 5 years ago
Does sound like a bug, have you experienced any actual problem due to this @lilfolr?
Yeah, so our app has to define the scope to ensure the service worker doesn't affect other applications under the same domain. When we define the scope the above method can't find the registered service worker to update it.
We have a workaround though - basically set autoUpdate
to false and manually check for updates in the app (specifying the scope)
ie:
swUpdate() {
navigator.serviceWorker.getRegistration(SCOPE).then((registration) => {
if (!registration) return;
return registration.update();
});
}
@lilfolr sounds legit, would you consider sending a PR our way?
Can do. Have a bit on at work atm, but I'll try get something out for you to review in the coming weeks
Should the getRegistration method in the runtime template optionally include the scope as an arg (if one has been defined)?
https://github.com/NekR/offline-plugin/blob/e2fd1ab6126664a72e6529b7d6f19c3c80e60099/tpls/runtime-template.js#L223
So something like this: