1// Import and configure the Firebase SDK 2// These scripts are made available when the app is served or deployed on Firebase Hosting 3// If you do not serve/host your project using Firebase Hosting see https://firebase.google.com/docs/web/setup 4 5importScripts('https://www.gstatic.com/firebasejs/7.14.2/firebase-app.js'); 6importScripts('https://www.gstatic.com/firebasejs/7.14.2/firebase-messaging.js'); 7var firebaseConfig = { 8 apiKey: "AIzaSyBk9etPb9VuCNwU1YLpc0BWFTIL7JWTPlA", 9 authDomain: "push-notifn.firebaseapp.com", 10 databaseURL: "https://push-notifn.firebaseio.com", 11 projectId: "push-notifn", 12 storageBucket: "push-notifn.appspot.com", 13 messagingSenderId: "856756086450", 14 appId: "1:856756086450:web:69a8cf9cf2840dca704bab", 15 measurementId: "G-9T800JFR5Q" 16 }; 17 firebase.initializeApp(firebaseConfig); 18 19const messaging = firebase.messaging(); 20 21/** 22 * Here is is the code snippet to initialize Firebase Messaging in the Service 23 * Worker when your app is not hosted on Firebase Hosting. 24 25 // [START initialize_firebase_in_sw] 26 // Give the service worker access to Firebase Messaging. 27 // Note that you can only use Firebase Messaging here, other Firebase libraries 28 // are not available in the service worker. 29 importScripts('https://www.gstatic.com/firebasejs/7.14.2/firebase-app.js'); 30 importScripts('https://www.gstatic.com/firebasejs/7.14.2/firebase-messaging.js'); 31 32 // Initialize the Firebase app in the service worker by passing in 33 // your app's Firebase config object. 34 // https://firebase.google.com/docs/web/setup#config-object 35 firebase.initializeApp({ 36 apiKey: 'api-key', 37 authDomain: 'project-id.firebaseapp.com', 38 databaseURL: 'https://project-id.firebaseio.com', 39 projectId: 'project-id', 40 storageBucket: 'project-id.appspot.com', 41 messagingSenderId: 'sender-id', 42 appId: 'app-id', 43 measurementId: 'G-measurement-id', 44 }); 45 46 // Retrieve an instance of Firebase Messaging so that it can handle background 47 // messages. 48 const messaging = firebase.messaging(); 49 // [END initialize_firebase_in_sw] 50 **/ 51 52 53// If you would like to customize notifications that are received in the 54// background (Web app is closed or not in browser focus) then you should 55// implement this optional method. 56// [START background_handler] 57messaging.setBackgroundMessageHandler(function(payload) { 58 console.log('[firebase-messaging-sw.js] Received background message ', payload); 59 // Customize notification here 60 const notificationTitle = payload.data.title; 61 const notificationOptions = { 62 body: payload.data.body, 63 image: payload.data.image, 64 icon:'/nero-com-wGlobal/wGlobal/layout/scripts/push-notfn/nero_white.png', 65 click_action: payload.data.click_action, 66 data: { 67 click_action: payload.data.click_action 68 } 69 70 }; 71 72self.addEventListener('notificationclick', function(event) { 73console.log(event.notification.data.click_action); 74if (!event.action) { 75// Was a normal notification click 76console.log('Notification Click.'); 77self.clients.openWindow(event.notification.data.click_action, '_blank') 78event.notification.close(); 79return; 80}else{ 81event.notification.close(); 82} 83}); 84 85 return self.registration.showNotification(notificationTitle, 86 notificationOptions); 87 88 89});
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.