if ('function' === typeof importScripts) { // eslint-disable-next-line no-undef importScripts('https://www.gstatic.com/firebasejs/8.2.0/firebase-app.js'); // eslint-disable-next-line no-undef importScripts('https://www.gstatic.com/firebasejs/8.2.0/firebase-messaging.js'); // eslint-disable-next-line no-undef const firebaseConfig = { apiKey: '', authDomain: '', databaseURL: '', projectId: '', storageBucket: '', messagingSenderId: '', appId: '', measurementId: '' }; // eslint-disable-next-line no-undef firebase.initializeApp(firebaseConfig); const COLLECTIONS_PORTAL_BROADCAST_CHANNEL = 'COLLECTIONS_PORTAL_BROADCAST_CHANNEL'; const bc = new BroadcastChannel(COLLECTIONS_PORTAL_BROADCAST_CHANNEL); // Retrieve firebase messaging // eslint-disable-next-line no-undef const messaging = firebase.messaging(); messaging.onBackgroundMessage(function (response) { if (response?.data?.payload) { bc.postMessage(response.data.payload); } }); } // Initialize the Firebase app in the service worker by passing the generated config