2self.addEventListener('push', function (event) {
3 if (event.data == null) return;
4 var json = event.data.json();
5 const options = { body: json.body, icon: '/favicon-303x303.png', data: { url: json.url } };
6 if (json.icon) { options.icon = '/images/notify/icons128-' + json.icon + '.png'; }
7 event.waitUntil(self.registration.showNotification(json.title, options));
10self.addEventListener('notificationclick', function (event) {
11 event.notification.close();
12 if ((event.notification.data.url != null) && (event.notification.data.url != '')) { event.waitUntil(self.clients.openWindow(event.notification.data.url)); }