// Scripts for firebase and firebase messaging
importScripts('https://www.gstatic.com/firebasejs/8.2.0/firebase-app.js');
importScripts('https://www.gstatic.com/firebasejs/8.2.0/firebase-messaging.js');

// Initialize the Firebase app in the service worker by passing the generated config
var firebaseConfig = {
  apiKey: "AIzaSyBwu7Kj26VW6wQ_kWqGm9OV_oRRlsHqpHs",
  authDomain: "kns-infra-bd.firebaseapp.com",
  databaseURL: "https://kns-infra-bd.firebaseio.com",
  projectId: "kns-infra-bd",
  storageBucket: "kns-infra-bd.appspot.com",
  messagingSenderId: "473818967397",
  appId: "1:473818967397:web:2c90af6a41eaac0173858c",
  measurementId: "G-2XWSLJP4DP"
};

firebase.initializeApp(firebaseConfig);

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

messaging.onBackgroundMessage(function(payload) {
  console.log('Received background message ', payload);

  const notificationTitle = payload.notification.title;
  const notificationOptions = {
    body: payload.notification.body,
  };

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