importScripts(
    'https://www.gstatic.com/firebasejs/9.13.0/firebase-app-compat.js'
)
importScripts(
    'https://www.gstatic.com/firebasejs/9.13.0/firebase-messaging-compat.js'
)
firebase?.initializeApp({
    apiKey: 'AIzaSyCeaw_gVN0iQwFHyuF8pQ6PbVDmSVQw8AY',
    authDomain: 'stackfood-bd3ee.firebaseapp.com',
    projectId: 'stackfood-bd3ee',
    storageBucket: 'stackfood-bd3ee.appspot.com',
    messagingSenderId: '1049699819506',
    appId: '1:1049699819506:web:a4b5e3bedc729aab89956b',
    measurementId: 'G-2QNRKR9K5R',
})

// Retrieve firebase messaging
const messaging = firebase?.messaging()

messaging.onBackgroundMessage(function (payload) {
    const notificationTitle = payload.notification.title
    const notificationOptions = {
        body: payload.notification.body,
    }

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