|
|
const usePwa = location.protocol === 'https:';
|
|
|
const isHttps = location.protocol === 'https:';
|
|
|
const usePwa = isHttps;
|
|
|
|
|
|
window.addEventListener('load', function() {
|
|
|
if ('serviceWorker' in navigator) {
|
...
|
...
|
@@ -14,15 +15,17 @@ window.addEventListener('load', function() { |
|
|
console.log('SW registration failed: ', err);
|
|
|
});
|
|
|
} else {
|
|
|
navigator.serviceWorker.getRegistrations().then(function(registrations) {
|
|
|
for (let registration of registrations) {
|
|
|
registration.unregister().then(result => {
|
|
|
console.log('SW unregisted: ', result);
|
|
|
}).catch(err => {
|
|
|
console.log('SW unregistration failed: ', err);
|
|
|
});
|
|
|
}
|
|
|
});
|
|
|
if (isHttps) {
|
|
|
navigator.serviceWorker.getRegistrations().then(function(registrations) {
|
|
|
for (let registration of registrations) {
|
|
|
registration.unregister().then(result => {
|
|
|
console.log('SW unregisted: ', result);
|
|
|
}).catch(err => {
|
|
|
console.log('SW unregistration failed: ', err);
|
|
|
});
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}); |
...
|
...
|
|