1importScripts('https://www.gstatic.com/firebasejs/3.7.2/firebase-app.js'); 2importScripts('https://www.gstatic.com/firebasejs/3.7.2/firebase-messaging.js'); 3 4firebase.initializeApp({ 5 messagingSenderId: "934654383868", 6}); 7 8const messaging = firebase.messaging(); 9 10// Customize notification handler 11messaging.setBackgroundMessageHandler(function(payload) { 12 console.log('Handling background message', payload); 13 14 // Copy data object to get parameters in the click handler 15 payload.data.data = JSON.parse(JSON.stringify(payload.data)); 16 17 return self.registration.showNotification(payload.data.title, payload.data); 18}); 19 20self.addEventListener('notificationclick', function(event) { 21 const target = event.notification.data.click_action || '/'; 22 event.notification.close(); 23 24 // This looks to see if the current is already open and focuses if it is 25 event.waitUntil(clients.matchAll({ 26 type: 'window', 27 includeUncontrolled: true 28 }).then(function(clientList) { 29 // clientList always is empty?! 30 for (var i = 0; i < clientList.length; i++) { 31 var client = clientList[i]; 32 if (client.url === target && 'focus' in client) { 33 return client.focus(); 34 } 35 } 36 37 return clients.openWindow(target); 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.