2021-02-09 10:35:03 +03:00
|
|
|
|
|
|
|
self.addEventListener('push', function (event) {
|
2021-02-10 02:31:50 +03:00
|
|
|
if (event.data == null) return;
|
|
|
|
var json = event.data.json();
|
2021-02-10 12:31:52 +03:00
|
|
|
const options = { body: json.body, icon: '/favicon-303x303.png', data: { url: json.url } };
|
2021-02-10 02:31:50 +03:00
|
|
|
if (json.icon) { options.icon = '/images/notify/icons128-' + json.icon + '.png'; }
|
2021-02-10 12:31:52 +03:00
|
|
|
event.waitUntil(self.registration.showNotification(json.title, options));
|
2021-02-09 10:35:03 +03:00
|
|
|
});
|
|
|
|
|
2021-02-10 02:31:50 +03:00
|
|
|
self.addEventListener('notificationclick', function (event) {
|
|
|
|
event.notification.close();
|
2021-02-10 12:31:52 +03:00
|
|
|
if ((event.notification.data.url != null) && (event.notification.data.url != '')) { event.waitUntil(self.clients.openWindow(event.notification.data.url)); }
|
2021-02-10 02:31:50 +03:00
|
|
|
});
|