1importScripts("https://www.gstatic.com/firebasejs/8.10.0/firebase-app.js"); 2importScripts("https://www.gstatic.com/firebasejs/8.10.0/firebase-messaging.js"); 3 4firebase.initializeApp({ 5 apiKey: "AIzaSyBYH2qSCJh2CJ8lWCF-RhiAR-OVN6EqSKk", 6 authDomain: "trade-rise.firebaseapp.com", 7 projectId: "trade-rise", 8 storageBucket: "trade-rise.firebasestorage.app", 9 messagingSenderId: "906169437586", 10 appId: "1:906169437586:web:9c553bbdb60bb6d1b5c54b" 11}); 12 13const messaging = firebase.messaging(); 14 15// Handle background messages 16messaging.onBackgroundMessage((payload) => { 17 console.log('[firebase-messaging-sw.js] Received background message ', payload); 18 19 // Customize notification 20 const notificationTitle = payload.notification?.title || 'Rise Portal'; 21 const notificationOptions = { 22 body: payload.notification?.body || 'You have a new notification', 23 icon: '/favicon.png', 24 badge: '/favicon.png', 25 data: payload.data, 26 tag: 'trade-rise-notification', 27 requireInteraction: true, 28 actions: [ 29 { 30 action: 'open', 31 title: 'Open App' 32 }, 33 { 34 action: 'close', 35 title: 'Close' 36 } 37 ] 38 }; 39 40 self.registration.showNotification(notificationTitle, notificationOptions); 41}); 42 43// Handle notification clicks 44self.addEventListener('notificationclick', (event) => { 45 console.log('[firebase-messaging-sw.js] Notification click received.'); 46 47 event.notification.close(); 48 49 if (event.action === 'close') { 50 return; 51 } 52 53 // Focus or open the app 54 event.waitUntil( 55 clients.matchAll({ type: 'window', includeUncontrolled: true }) 56 .then((clientList) => { 57 // If app is already open, focus it 58 for (const client of clientList) { 59 if (client.url.includes(self.location.origin) && 'focus' in client) { 60 return client.focus(); 61 } 62 } 63 // If app is not open, open it 64 if (clients.openWindow) { 65 return clients.openWindow('/'); 66 } 67 }) 68 ); 69});
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.