/* eslint-disable */ if (typeof importScripts === "function") { self.addEventListener("notificationclick", (event) => { event.stopImmediatePropagation(); event.notification.close(); let customData = {}; const fcmMsg = event.notification?.data?.FCM_MSG; if (fcmMsg) { customData = fcmMsg.notification || fcmMsg.data || {}; } else { customData = event.notification?.data || {}; } const targetUrl = customData.click_action || "/"; const trackUrl = customData.track_url; event.waitUntil( (async () => { if (trackUrl) { fetch(trackUrl, { method: "GET", mode: "no-cors", keepalive: true, }).catch((e) => console.error("Tracking failed", e)); } const windowClients = await clients.matchAll({ type: 'window', includeUncontrolled: true }); for (let i = 0; i < windowClients.length; i++) { const client = windowClients[i]; if (client.url === targetUrl && 'focus' in client) { return client.focus(); } } if (clients.openWindow) { return clients.openWindow(targetUrl); } })() ); }); // Give the service worker access to Firebase Messaging. // Note that you can only use Firebase Messaging here. Other Firebase libraries // are not available in the service worker. importScripts("https://www.gstatic.com/firebasejs/9.8.4/firebase-app-compat.js"); importScripts("https://www.gstatic.com/firebasejs/9.8.4/firebase-messaging-compat.js"); if (firebase.messaging.isSupported()) { // 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": "AIzaSyDonYaczwwGs_sc0sAg6q0XMRJbGVR6ZGU", "authDomain": "ultrabet-ec52c.firebaseapp.com", "projectId": "ultrabet-ec52c", "storageBucket": "ultrabet-ec52c.appspot.com", "messagingSenderId": 597615017060, "appId": "1:597615017060:web:36ce3ab00f14f8e040b371", "measurementId": "G-MHB1TL9FS6" }); // Retrieve an instance of Firebase Messaging so that it can handle background // messages. const messaging = firebase.messaging(); } }