Merge branch 'master' of https://github.com/sebathefox/skolehjem-webapp into master
This commit is contained in:
commit
330cb62fd0
|
@ -34,7 +34,8 @@ class PushNews extends Notification
|
||||||
->title('Ny Nyhed')
|
->title('Ny Nyhed')
|
||||||
->icon('/images/icons/appIcon.png')
|
->icon('/images/icons/appIcon.png')
|
||||||
->body('Der er en ny nyhed i ekapp\'en')
|
->body('Der er en ny nyhed i ekapp\'en')
|
||||||
->action('Se nyheder', 'root.index');
|
->badge('/images/icons/appIcon.png')
|
||||||
|
->action('Se nyheder', route('root.index'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -25,7 +25,6 @@ const assets = [
|
||||||
'/images/logos/Logo-hvid.svg',
|
'/images/logos/Logo-hvid.svg',
|
||||||
'/images/logos/Logo-normal.svg',
|
'/images/logos/Logo-normal.svg',
|
||||||
'/images/icons/Logout.svg'
|
'/images/icons/Logout.svg'
|
||||||
|
|
||||||
];
|
];
|
||||||
|
|
||||||
// install event
|
// install event
|
||||||
|
@ -58,18 +57,22 @@ self.addEventListener('activate', evt => {
|
||||||
|
|
||||||
self.addEventListener('fetch', evt => {
|
self.addEventListener('fetch', evt => {
|
||||||
console.log('fetch event');
|
console.log('fetch event');
|
||||||
evt.respondWith(
|
|
||||||
caches.match(evt.request).then(cacheRes => {
|
if(!navigator.onLine)
|
||||||
return cacheRes || fetch(evt.request).then(fetchRes => {
|
evt.respondWith(
|
||||||
|
caches.match(evt.request).then(cacheRes => {
|
||||||
|
return cacheRes || caches.match('/offline.html');
|
||||||
|
})
|
||||||
|
);
|
||||||
|
else
|
||||||
|
evt.respondWith(
|
||||||
|
fetch(evt.request).then(fetchRes => {
|
||||||
return caches.open(dynamicCacheName).then(cache => {
|
return caches.open(dynamicCacheName).then(cache => {
|
||||||
cache.put(evt.request.url, fetchRes.clone());
|
cache.put(evt.request.url, fetchRes.clone());
|
||||||
return fetchRes;
|
return fetchRes;
|
||||||
})
|
})
|
||||||
});
|
})
|
||||||
}).catch(function () {
|
);
|
||||||
return caches.match('/offline.html');
|
|
||||||
})
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
self.addEventListener('push', function(event) {
|
self.addEventListener('push', function(event) {
|
||||||
|
@ -84,7 +87,18 @@ self.addEventListener('push', function(event) {
|
||||||
event.waitUntil(self.registration.showNotification(msg.title, {
|
event.waitUntil(self.registration.showNotification(msg.title, {
|
||||||
body: msg.body,
|
body: msg.body,
|
||||||
icon: msg.icon,
|
icon: msg.icon,
|
||||||
|
badge: msg.badge,
|
||||||
actions: msg.actions
|
actions: msg.actions
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
self.addEventListener('notificationclick', (event) => {
|
||||||
|
event.notification.close();
|
||||||
|
|
||||||
|
if (event.action === 'some_action') {
|
||||||
|
self.clients.openWindow('/home');
|
||||||
|
} else {
|
||||||
|
self.clients.openWindow('/')
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
Loading…
Reference in New Issue