...
|
...
|
@@ -8,10 +8,16 @@ function register() { |
|
|
|
|
|
navigator.serviceWorker.register(`/sw.js?t=${t}&staticServer=${staticServer}`, {
|
|
|
scope: '/'
|
|
|
}).then(registration => {
|
|
|
console.log('SW registered: ', registration);
|
|
|
}).then(() => {
|
|
|
if (window._hmt && window._hmt.push) {
|
|
|
window._hmt.push(['_trackEvent', 'SW registered', 'SUCCESS',
|
|
|
document.title, location.href]);
|
|
|
}
|
|
|
}).catch(err => {
|
|
|
console.log('SW registration failed: ', err);
|
|
|
if (window._hmt && window._hmt.push) {
|
|
|
window._hmt.push(['_trackEvent', 'SW registered', 'FAILED',
|
|
|
document.title, JSON.stringify(err)]);
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
|
...
|
...
|
@@ -19,10 +25,16 @@ function unregister() { |
|
|
if (isHttps) {
|
|
|
navigator.serviceWorker.getRegistrations().then(registrations => {
|
|
|
for (let registration of registrations) {
|
|
|
registration.unregister().then(result => {
|
|
|
console.log('SW unregisted: ', result);
|
|
|
registration.unregister().then(() => {
|
|
|
if (window._hmt && window._hmt.push) {
|
|
|
window._hmt.push(['_trackEvent', 'SW unregistered', 'SUCCESS',
|
|
|
document.title, location.href]);
|
|
|
}
|
|
|
}).catch(err => {
|
|
|
console.log('SW unregistration failed: ', err);
|
|
|
if (window._hmt && window._hmt.push) {
|
|
|
window._hmt.push(['_trackEvent', 'SW unregistered', 'FAILED',
|
|
|
document.title, JSON.stringify(err)]);
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
});
|
...
|
...
|
|