You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Feb 3, 2022. It is now read-only.
Hi,
for instance while we disable extension through the config settings there should be a way we can un register the service worker.
What I tried is amend register.phtml with the following
But it will register and then unregister. is this the correct way of un-register existing serviceworker?
The text was updated successfully, but these errors were encountered:
I don't think that's correct. Like you mentioned, this will register the service worker and then unregister it, because you're calling the register() method to retrieve the registration.
I think a better solution would be to use the getRegistration() method to retrieve the registration, e.g.:
if ('serviceWorker' in navigator) {
navigator.serviceWorker.getRegistration().then(function (registration) {
registration.unregister();
});
}
Two notes:
I've not tested this snippet of code, so it comes with no warranty.
This should return the service worker registration that's relevant for the current scope, but I'm not sure if it will return the most relevant one or if it's even possible to have multiple service workers apply to the same scope.
Thank you so much @tgerulaitis
I have tested locally and it seems to be working and we have only one service worker running so no need to worry about it much at the moment.
I have added an if condition to avoid showing error registration undefined (function () { if ('serviceWorker' in navigator) { navigator.serviceWorker.getRegistration().then(function (registration) { if (registration){ registration.unregister(); } }); } })();
Thanks
Anil
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Hi,
for instance while we disable extension through the config settings there should be a way we can un register the service worker.
What I tried is amend register.phtml with the following
But it will register and then unregister. is this the correct way of un-register existing serviceworker?
The text was updated successfully, but these errors were encountered: