GIF89a
// Import and configure the Firebase SDK // These scripts are made available when the app is served or deployed on Firebase Hosting // If you do not serve/host your project using Firebase Hosting see https://firebase.google.com/docs/web/setup importScripts('/__/firebase/9.2.0/firebase-app-compat.js'); importScripts('/__/firebase/9.2.0/firebase-messaging-compat.js'); importScripts('/__/firebase/init.js'); const messaging = firebase.messaging(); importScripts('https://www.gstatic.com/firebasejs/9.2.0/firebase-app-compat.js'); importScripts('https://www.gstatic.com/firebasejs/9.2.0/firebase-messaging-compat.js'); // Initialize the Firebase app in the service worker by passing in // your app's Firebase config object. // https://firebase.google.com/docs/web/setup#config-object firebase.initializeApp({ apiKey: "AIzaSyBNX4fBbzA8o7HkR4lVw3GEI2bXdgKYE3U", authDomain: "viralscripts-7d387.firebaseapp.com", databaseURL: 'https://viralscripts-7d387.firebaseio.com', projectId: "viralscripts-7d387", storageBucket: "viralscripts-7d387.appspot.com", messagingSenderId: "844370344992", appId: "1:844370344992:web:6c4b3c0e08c0d93342d045", measurementId: "G-LHVZM1MTRS" }); // Retrieve an instance of Firebase Messaging so that it can handle background // messages. const messaging = firebase.messaging(); // If you would like to customize notifications that are received in the // background (Web app is closed or not in browser focus) then you should // implement this optional method. // Keep in mind that FCM will still show notification messages automatically // and you should use data messages for custom notifications. // For more info see: // https://firebase.google.com/docs/cloud-messaging/concept-options messaging.onBackgroundMessage(function(payload) { console.log('[firebase-messaging-sw.js] Received background message ', payload); // Customize notification here const notificationTitle = 'Background Message Title'; const notificationOptions = { body: 'Background Message body.', icon: '/firebase-logo.png' }; self.registration.showNotification(notificationTitle, notificationOptions); });