diff --git a/client/public/firebase-messaging-sw.js b/client/public/firebase-messaging-sw.js index 7149ee389..de6f9e9a2 100644 --- a/client/public/firebase-messaging-sw.js +++ b/client/public/firebase-messaging-sw.js @@ -42,3 +42,8 @@ self.addEventListener("notificationclick", function (event) { // ... console.log("SW notificationclick", event); }); + +self.addEventListener("message", (message) => { + console.log("Push from SW", message); +// registration.showNotification("Push from SW" + JSON.stringify(message.data)); +}); diff --git a/client/src/App/App.container.jsx b/client/src/App/App.container.jsx index 284d71d31..7ea2bd371 100644 --- a/client/src/App/App.container.jsx +++ b/client/src/App/App.container.jsx @@ -130,6 +130,13 @@ export default class AppContainer extends Component { navigator.serviceWorker.addEventListener("message", (message) => { console.log("Comp Did Mount", message); notification["info"]({ message: JSON.stringify(message.data) }); + navigator.serviceWorker + .getRegistration() + .then((registration) => + registration.showNotification( + "Comp Did" + JSON.stringify(message.data) + ) + ); }); } diff --git a/server/firebase/firebase-handler.js b/server/firebase/firebase-handler.js index 0bcd5a016..b609f21b2 100644 --- a/server/firebase/firebase-handler.js +++ b/server/firebase/firebase-handler.js @@ -13,9 +13,13 @@ exports.sendNotification = (req, res) => { // const { ids } = req.body; // const url = cloudinary.utils.download_zip_url({ public_ids: ids }); + //Prod + // var registrationToken = + // "c3-6vUcehzdDe4rdfUr1JP:APA91bEbZiO1j7M4O1IHzWEiczqNoT7udFH9wE7m-Ob-2wRRRxEv6gyBY64fYVvFkfOGdLNJic6kcAr7ImpUy3jHXlWvUqtdUQ-uRhZoWa-IgJSCIgfT7pjDnvCakvr45YyAms4neP1s"; + + //Dev var registrationToken = "dwsrcoeaIpwEmSzrVkE-_V:APA91bFurr0yCN-yXcaNrJvn8_f47I4vb4avxeS0NR5SCBPNADFB-gC79Hdmj7wqPccPmZCx0NzA_Dqi1lLYegpN-tFvANaK9I00oOSsFnOxv6KNZDLW0WguwFA0vQN8X50BaGuLTQqM"; - var message = { data: { title: "850",