importScripts('https://www.gstatic.com/firebasejs/9.0.0/firebase-app-compat.js');
importScripts('https://www.gstatic.com/firebasejs/9.0.0/firebase-messaging-compat.js');

firebase.initializeApp({
    apiKey: "AIzaSyDGlBocq5uuiaU8lDi1M1lHRV20xJSjW8g",
    projectId: "sna-crm-software",
    messagingSenderId: "1004217416886",
    appId: "1:1004217416886:web:29790211f3156c07c0fa17"
});

const messaging = firebase.messaging();

// This handles the notification when the PWA is in the background
messaging.onBackgroundMessage((payload) => {
    const notificationTitle = payload.notification.title;
    const notificationOptions = {
        body: payload.notification.body,
        icon: '/logo.png'
    };
    self.registration.showNotification(notificationTitle, notificationOptions);
});