40 lines
1.4 KiB
JavaScript
40 lines
1.4 KiB
JavaScript
// 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
|
|
const firebaseConfig = {
|
|
apiKey: "AIzaSyDPLT8GiDHDR1R4nI66Qi0BY1aYviDPioc",
|
|
authDomain: "imex-dev.firebaseapp.com",
|
|
databaseURL: "https://imex-dev.firebaseio.com",
|
|
projectId: "imex-dev",
|
|
storageBucket: "imex-dev.appspot.com",
|
|
messagingSenderId: "759548147434",
|
|
appId: "1:759548147434:web:e8239868a48ceb36700993",
|
|
measurementId: "G-K5XRBVVB4S",
|
|
};
|
|
// const firebaseConfig = {
|
|
// apiKey: "AIzaSyDSezy-jGJreo7ulgpLdlpOwAOrgcaEkhU",
|
|
// authDomain: "imex-prod.firebaseapp.com",
|
|
// databaseURL: "https://imex-prod.firebaseio.com",
|
|
// projectId: "imex-prod",
|
|
// storageBucket: "imex-prod.appspot.com",
|
|
// messagingSenderId: "253497221485",
|
|
// appId: "1:253497221485:web:3c81c483b94db84b227a64",
|
|
// measurementId: "G-NTWBKG2L0M",
|
|
// }
|
|
|
|
firebase.initializeApp(firebaseConfig);
|
|
|
|
// Retrieve firebase messaging
|
|
const messaging = firebase.messaging();
|
|
|
|
messaging.onBackgroundMessage(function (payload) {
|
|
console.log("FCM BG MSG", payload);
|
|
// Customize notification here
|
|
const channel = new BroadcastChannel("imex-sw-messages");
|
|
channel.postMessage(payload);
|
|
|
|
//self.registration.showNotification(notificationTitle, notificationOptions);
|
|
});
|