1// Give the service worker access to Firebase Messaging. 2// Note that you can only use Firebase Messaging here. Other Firebase libraries 3// are not available in the service worker. 4importScripts('https://www.gstatic.com/firebasejs/8.10.1/firebase-app.js'); 5importScripts('https://www.gstatic.com/firebasejs/8.10.1/firebase-messaging.js'); 6 7// Initialize the Firebase app in the service worker by passing in 8// your app's Firebase config object. 9// https://firebase.google.com/docs/web/setup#config-object 10firebase.initializeApp({ 11 apiKey: "AIzaSyCsHFId_B9mLGsBxjiUPpafY-MfyLcoCnw", 12 authDomain: "shalom-tv-cd495.firebaseapp.com", 13 databaseURL: "https://shalom-tv-cd495.firebaseio.com", 14 projectId: "shalom-tv-cd495", 15 storageBucket: "shalom-tv-cd495.appspot.com", 16 messagingSenderId: "871376473990", 17 appId: "1:871376473990:web:ce2a85b2f3aa0b1178a607", 18 measurementId: "G-2VRZD8BJTZ" 19}); 20 21// Retrieve an instance of Firebase Messaging so that it can handle background 22// messages. 23const messaging = firebase.messaging(); 24messaging.onBackgroundMessage((payload) => { 25 // console.log( 26 // '[firebase-messaging-sw.js] Received background message ', 27 // payload 28 // ); 29 // Customize notification here 30 if (payload?.data ?? false) { 31 try { 32 const sanitizedCatName = encodeURIComponent(payload?.data?.name.replace(/[|:;.,\s]/g, "").toLowerCase()); // Sanitizing category name for URL 33 if (payload?.data?.content_type === "video" || payload?.data?.content_type === "audio") { 34 const notificationTitle = payload.data.title; 35 const notificationOptions = { 36 body: payload.data.message, 37 icon: payload.data.thumb_url, 38 data: { 39 url: `${localStorage.getItem('websiteurl')}/${payload?.data?.content_type === "video" ? 'watch' : 'radio'}/cat/${sanitizedCatName}/${payload?.data?.entryid}`, 40 }, 41 }; 42 43 const notification = new Notification(notificationTitle, notificationOptions); 44 notification.onclick = () => { 45 window.open(notification.data.url, '_self'); 46 }; 47 } 48 else if (payload?.data?.content_type === "youtube") { 49 50 const notificationTitle = payload.data.title; 51 const notificationOptions = { 52 body: payload.data.message, 53 icon: payload.data.thumb_url, 54 data: { 55 url: payload.data.Url, 56 }, 57 }; 58 59 const notification = new Notification(notificationTitle, notificationOptions); 60 notification.onclick = () => { 61 window.open(notification.data.url, '_blank'); 62 }; 63 } else if (payload?.data?.content_type === "rss_feed") { 64 const notificationTitle = payload.data.title; 65 const notificationOptions = { 66 body: payload.data.message, 67 icon: payload.data.thumb_url, 68 data: { 69 url: `${localStorage.getItem('websiteurl')}/feeds/cat/rssfeed/?downloadurl=${payload.data.Url}`, 70 }, 71 }; 72 73 const notification = new Notification(notificationTitle, notificationOptions); 74 notification.onclick = () => { 75 window.open(notification.data.url, '_self'); 76 }; 77 } else if (payload?.data?.content_type === "pdf") { 78 const notificationTitle = payload.data.title; 79 const notificationOptions = { 80 body: payload.data.message, 81 icon: payload.data.thumb_url, 82 data: { 83 url: payload.data.Url, 84 }, 85 }; 86 87 const notification = new Notification(notificationTitle, notificationOptions); 88 notification.onclick = () => { 89 window.open(notification.data.url, '_blank'); 90 }; 91 } 92 } catch (error) { 93 94 } 95 } 96 else { 97 const notificationTitle = payload.notification.title; 98 const notificationOptions = { 99 body: payload.notification.body, 100 icon: payload.notification.image 101 }; 102 103 self.registration.showNotification(notificationTitle, notificationOptions); 104 } 105 const notificationTitle = payload.notification.title; 106 const notificationOptions = { 107 body: payload.notification.body, 108 icon: payload.notification.image 109 }; 110 111 self.registration.showNotification(notificationTitle, notificationOptions); 112});
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.