1self.addEventListener('push', (event) => { 2 let payload = {}; 3 try { 4 payload = event.data ? event.data.json() : {}; 5 } catch (error) { 6 payload = { body: event.data ? event.data.text() : '' }; 7 } 8 9 const title = payload.title || 'Notification'; 10 const options = { 11 body: payload.body || '', 12 icon: payload.icon || '/favicon.ico', 13 badge: payload.badge || '/favicon.ico', 14 data: payload.data || payload, 15 tag: payload.tag || 'tenant-inbox', 16 }; 17 18 event.waitUntil(self.registration.showNotification(title, options)); 19}); 20 21self.addEventListener('notificationclick', (event) => { 22 event.notification.close(); 23 const url = event.notification?.data?.url || '/notifications'; 24 25 event.waitUntil( 26 self.clients.matchAll({ type: 'window', includeUncontrolled: true }).then((clients) => { 27 for (const client of clients) { 28 if (client.url.includes(self.location.origin) && 'focus' in client) { 29 client.navigate(url); 30 return client.focus(); 31 } 32 } 33 if (self.clients.openWindow) { 34 return self.clients.openWindow(url); 35 } 36 return undefined; 37 }) 38 ); 39});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.