mirror of
https://git.steelants.cz/JonatanRek/VUE_GabenParadise.git
synced 2026-10-11 11:25:32 +00:00
Some Tweeks for Notifications
This commit is contained in:
1 parent
38e0f3ae49
commit
cc185b344e
4 files changed
+90
-61
No files matched your search
+31
-16
@@ -1,25 +1,40 @@
|
||||
self.__precacheManifest = [].concat(self.__precacheManifest || []);
|
||||
|
||||
// workbox.setConfig({
|
||||
// debug: true
|
||||
// });
|
||||
|
||||
workbox.precaching.precacheAndRoute(self.__precacheManifest, {});
|
||||
self.skipWaiting();
|
||||
console.log("Skiping Waiting");
|
||||
|
||||
console.log('Loading SW');
|
||||
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("push", function(event) {
|
||||
if (event.data) {
|
||||
var data = event.data.json();
|
||||
var notOptions = {
|
||||
body: data.notification.body,
|
||||
icon: data.notification.image || null
|
||||
};
|
||||
if (data.data) {
|
||||
console.log("dataFound");
|
||||
console.log(data.data.data);
|
||||
notOptions.actions = JSON.parse(data.data.actions);
|
||||
notOptions.data = JSON.parse(data.data.data);
|
||||
}
|
||||
event.waitUntil(
|
||||
self.registration.showNotification(data.notification.title, notOptions)
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
self.addEventListener("notificationclick", function (event) {
|
||||
const promiseChain = clients.openWindow("https://gabenparadise.com/");
|
||||
event.waitUntil(promiseChain);
|
||||
self.addEventListener("notificationclick", function(event) {
|
||||
if (event.notification) {
|
||||
var data = JSON.parse(event.notification.data.data);
|
||||
if (data[event.action]) {
|
||||
console.log(data);
|
||||
console.log(data[event.action]);
|
||||
clients.openWindow("" + data[event.action]);
|
||||
}
|
||||
}
|
||||
clients.openWindow("/");
|
||||
});
|
||||
|
||||
self.__precacheManifest = [].concat(self.__precacheManifest || []);
|
||||
workbox.precaching.precacheAndRoute(self.__precacheManifest, {});
|
||||
Reference in new issue
Block a user