1importScripts('https://www.gstatic.com/firebasejs/11.8.1/firebase-app-compat.js'); 2importScripts('https://www.gstatic.com/firebasejs/11.8.1/firebase-messaging-compat.js'); 3 4// Determine domain 5const hostname = self.location.hostname; 6 7// Define configs 8const firebaseConfig = hostname.includes('staging') 9 ? { 10 apiKey: "AIzaSyDQzsUeiKKP_78qWVVHguzFHaQIa4iLjUg", 11 authDomain: "luckydays-12290.firebaseapp.com", 12 projectId: "luckydays-12290", 13 storageBucket: "luckydays-12290.firebasestorage.app", 14 messagingSenderId: "1027003456063", 15 appId: "1:1027003456063:web:25bbf7b28035f1f828368a", 16 measurementId: "G-X4KF4J9PT8" 17 } 18 : { 19 apiKey: "AIzaSyChFRt13A7fA-s_9nRvpX6XHuMB7WR2qvU", 20 authDomain: "lucky-day-competitions-49a22.firebaseapp.com", 21 projectId: "lucky-day-competitions-49a22", 22 storageBucket: "lucky-day-competitions-49a22.firebasestorage.app", 23 messagingSenderId: "386526896521", 24 appId: "1:386526896521:web:88ffdeae665719738e0158", 25 measurementId: "G-RW0NJL3WTH" 26 }; 27 28 29 30firebase.initializeApp(firebaseConfig); 31 32const messaging = firebase.messaging(); 33 34messaging.onBackgroundMessage(function (payload) { 35 // Only show notification if payload does NOT have native notification block 36 if (hostname.includes('staging')) { 37 console.log('[firebase-messaging-sw.js] Received background message ', payload); 38 } 39 40 // If the payload contains a notification, we skip showing a custom notification (avoids duplication) 41 if (payload.notification) { 42 return; 43 } 44 45 const title = payload.data?.title || 'Lucky Days'; 46 const body = payload.data?.body || ''; 47 const icon = 'https://staging.luckydaycompetitions.com/wp-content/themes/luckydays23/images/pushicon.png'; 48 49 const notificationOptions = { 50 body: body, 51 icon: icon, 52 image: payload.data?.image || 'https://staging.luckydaycompetitions.com/wp-content/themes/luckydays23/images/pushicon.png', 53 data: { 54 url: payload.data?.url || 'https://www.luckydaycompetitions.com', 55 notificationId: payload.data?.notificationId, 56 messageId: payload.messageId, 57 } 58 }; 59 60 self.registration.showNotification(title, notificationOptions); 61}); 62 63self.addEventListener('notificationclick', function (event) { 64 event.notification.close(); 65 const notification = event.notification; 66 const clickUrl = notification.data?.url || 'https://www.luckydaycompetitions.com'; 67 68 fetch(`https://${hostname}/wp-json/fcm/v1/notification-clicked-logger`, { 69 method: 'POST', 70 headers: { 71 'Content-Type': 'application/json', 72 }, 73 body: JSON.stringify({ 74 notification_id: notification.data?.notificationId, 75 }), 76 }); 77 78 event.waitUntil( 79 clients.matchAll({ type: 'window', includeUncontrolled: true }).then(function (clientList) { 80 for (const client of clientList) { 81 if (client.url === clickUrl && 'focus' in client) { 82 return client.focus(); 83 } 84 } 85 if (clients.openWindow) { 86 return clients.openWindow(clickUrl); 87 } 88 }) 89 ); 90});
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.