Moved firebase messaging notification handling to messaging generation.

This commit is contained in:
Patrick Fic
2020-07-23 08:30:28 -07:00
parent ffedc41c26
commit 3eb2c0d787
5 changed files with 49 additions and 31 deletions

View File

@@ -61,14 +61,30 @@ export const logImEXEvent = (eventName, additionalParams, stateProp = null) => {
analytics.logEvent(eventName, eventParams);
};
messaging.onMessage((payload) => {
messaging.onMessage(async (payload) => {
console.log("**********UTILS Message received. ", payload);
navigator.serviceWorker.getRegistration().then((registration) => {
return registration.showNotification(
payload.notification.title + "from utils",
"[UTIL]" + payload.notification.title,
payload.notification
);
});
// if (!payload.clientId) return;
// // Get the client.
// const client = await clients.get(payload.clientId);
// // Exit early if we don't get the client.
// // Eg, if it closed.
// if (!client) return;
// // Send a message to the client.
// console.log("Posting to client.");
// client.postMessage({
// msg: "Hey I just got a fetch from you!",
// url: payload.request.url,
// });
// [START_EXCLUDE]
// Update the UI to include the received message.
//appendMessage(payload);