PWA update available notification (#42)
This commit is contained in:
parent
81e9eef154
commit
ff0f078ee6
5 changed files with 79 additions and 4 deletions
3
src/ServiceWorker/events.json
Normal file
3
src/ServiceWorker/events.json
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"SW_UPDATED": "swUpdated"
|
||||
}
|
||||
|
|
@ -19,3 +19,24 @@ workbox.routing.registerRoute(
|
|||
new RegExp('.*'),
|
||||
new workbox.strategies.StaleWhileRevalidate()
|
||||
);
|
||||
|
||||
// This code listens for the user's confirmation to update the app.
|
||||
self.addEventListener('message', (e) => {
|
||||
if (!e.data) {
|
||||
return;
|
||||
}
|
||||
|
||||
switch (e.data) {
|
||||
case 'skipWaiting':
|
||||
self.skipWaiting();
|
||||
break;
|
||||
default:
|
||||
// NOOP
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
workbox.core.clientsClaim();
|
||||
// The precaching code provided by Workbox.
|
||||
self.__precacheManifest = [].concat(self.__precacheManifest || []);
|
||||
workbox.precaching.precacheAndRoute(self.__precacheManifest, {});
|
||||
|
|
|
|||
Reference in a new issue