Moved firebase messaging notification handling to messaging generation.
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user