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