diff --git a/client/public/firebase-messaging-sw.js b/client/public/firebase-messaging-sw.js new file mode 100644 index 000000000..7ee3f3d98 --- /dev/null +++ b/client/public/firebase-messaging-sw.js @@ -0,0 +1,56 @@ +// 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 +let firebaseConfig; +switch (this.location.hostname) { + case "localhost": + 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", + }; + break; + case "test.imex.online": + firebaseConfig = { + apiKey: "AIzaSyBw7_GTy7GtQyfkIRPVrWHEGKfcqeyXw0c", + authDomain: "imex-test.firebaseapp.com", + projectId: "imex-test", + storageBucket: "imex-test.appspot.com", + messagingSenderId: "991923618608", + appId: "1:991923618608:web:633437569cdad78299bef5", + // measurementId: "${config.measurementId}", + }; + break; + case "imex.online": + default: + 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) { + // Customize notification here + const channel = new BroadcastChannel("imex-sw-messages"); + channel.postMessage(payload); + + //self.registration.showNotification(notificationTitle, notificationOptions); +}); diff --git a/client/src/App/App.jsx b/client/src/App/App.jsx index 50bde585a..4b80fb38e 100644 --- a/client/src/App/App.jsx +++ b/client/src/App/App.jsx @@ -150,7 +150,7 @@ export function App({ bodyshop, checkUserSession, currentUser, online, setOnline { - history(opt.label.props.to); - }} - onClear={() => setData([])} - > + setData([])}> { @@ -157,14 +156,7 @@ export default function GlobalSearch() { if (error) return ; return ( - { - history(opt.label.props.to); - }} - > + , - // label: t("menus.header.rescueme"), - // onClick: () => { - // window.open("https://imexrescue.com/", "_blank"); - // } - // }, + ...(InstanceRenderManager({ + imex: true, + rome: false, + promanager: false + }) + ? [ + { + key: "rescue", + icon: , + label: t("menus.header.rescueme"), + onClick: () => { + window.open("https://imexrescue.com/", "_blank"); + } + } + ] + : []), ...(InstanceRenderManager({ imex: true, diff --git a/client/src/utils/fcm-handler.js b/client/src/utils/fcm-handler.js index 0b44abb49..c6284c764 100644 --- a/client/src/utils/fcm-handler.js +++ b/client/src/utils/fcm-handler.js @@ -1,4 +1,5 @@ export default async function FcmHandler({ client, payload }) { + console.log("FCM", payload); switch (payload.type) { case "messaging-inbound": client.cache.modify({