Service worker

This commit is contained in:
Michel 2018-07-04 12:53:26 +02:00
parent bde15f3cf2
commit 5f7c53ba5f
2 changed files with 29 additions and 2 deletions

View File

@ -1,6 +1,8 @@
if ('serviceWorker' in navigator) {
var baseHref = (document.getElementsByTagName('base')[0] || {}).href;
if(baseHref){
navigator.serviceWorker.register(baseHref + 'service-worker.js');
navigator.serviceWorker.register(baseHref + 'service-worker.js').then(function() {
//console.log('Service Worker Registered');
});
}
}

View File

@ -1 +1,26 @@
self.addEventListener('fetch', (event) => {});
self.addEventListener('install', function(e) {
console.log('Install');
/*
e.waitUntil(
caches.open('airhorner').then(function(cache) {
return cache.addAll([
'/',
'/index.html',
'/index.html?homescreen=1',
'/?homescreen=1',
'/styles/main.css',
'/scripts/main.min.js',
'/sounds/airhorn.mp3'
]);
})
);
*/
});
self.addEventListener('fetch', function(event) {
console.log(event.request.url);
});
self.addEventListener('beforeinstallprompt', function(event) {
console.log('beforeinstallprompt');
});