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

firebase.initializeApp({
  apiKey: "AIzaSyAJpHPX2cjwxVmUCYoAWzhWtcuuV1dnfP4",
  authDomain: "goldapp-bdaf1.firebaseapp.com",
  projectId: "goldapp-bdaf1",
  storageBucket: "goldapp-bdaf1.firebasestorage.app",
  messagingSenderId: "581623454822",
  appId: "1:581623454822:web:1a56f3c2755d94bab961a7",
  measurementId: "G-ZT5NM5QFTK"
});

const messaging = firebase.messaging();

messaging.onBackgroundMessage((payload) => {
  console.log('[firebase-messaging-sw.js] Received background message ', payload);
  
  const notificationTitle = payload.notification.title;
  const notificationOptions = {
    body: payload.notification.body,
    icon: '/favicon.ico'
  };

  self.registration.showNotification(notificationTitle, notificationOptions);
});
