importScripts('https://www.gstatic.com/firebasejs/9.22.0/firebase-app-compat.js'); importScripts('https://www.gstatic.com/firebasejs/9.22.0/firebase-messaging-compat.js'); firebase.initializeApp({ apiKey: "AIzaSyDLUdJyF0Kv46xb2gJmzh9nykJt-jZ2U34", authDomain: "call-to-car-6542b.firebaseapp.com", databaseURL: "https://call-to-car-6542b-default-rtdb.europe-west1.firebasedatabase.app", projectId: "call-to-car-6542b", storageBucket: "call-to-car-6542b.firebasestorage.app", messagingSenderId: "740425848873", appId: "1:740425848873:web:16101ec70c39cc6503e438" }); const messaging = firebase.messaging(); messaging.onBackgroundMessage((payload) => { console.log('📬 Background message:', payload); const notificationTitle = payload.notification.title; const notificationOptions = { body: payload.notification.body, icon: '/icon-192x192.png', tag: 'new-message', requireInteraction: false }; return self.registration.showNotification(notificationTitle, notificationOptions); }); self.addEventListener('notificationclick', (event) => { console.log('🔔 Notification clicked'); event.notification.close(); event.waitUntil(clients.openWindow('/')); });
GetResponse