2020-08-10 18:04:18 +00:00
|
|
|
self.__precacheManifest = [].concat(self.__precacheManifest || []);
|
2020-08-10 12:35:19 +00:00
|
|
|
|
|
|
|
// workbox.setConfig({
|
|
|
|
// debug: true
|
|
|
|
// });
|
|
|
|
|
2020-08-10 18:04:18 +00:00
|
|
|
workbox.precaching.precacheAndRoute(self.__precacheManifest, {});
|
2020-08-10 12:35:19 +00:00
|
|
|
|
2020-08-10 18:04:18 +00:00
|
|
|
console.log('Loading SW');
|
2020-08-10 12:35:19 +00:00
|
|
|
self.addEventListener("push", function (event) {
|
|
|
|
console.log('Received a push message', event);
|
|
|
|
if (event.data) {
|
|
|
|
var data = event.data.json();
|
|
|
|
console.log(data);
|
|
|
|
event.waitUntil(self.registration.showNotification(data.notification.title, {
|
|
|
|
body: data.notification.body,
|
|
|
|
icon: data.notification.image || null
|
|
|
|
}));
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
self.addEventListener("notificationclick", function (event) {
|
|
|
|
const promiseChain = clients.openWindow("https://gabenparadise.com/");
|
|
|
|
event.waitUntil(promiseChain);
|
|
|
|
});
|