I have implemented push notifications for my PWA and my service worker (SW) is currently handling clicks on a notifications like this:
Client.openWindowusing URL parameters that contain some minimal information about the push notification
Point 1 works just as I want. But for 2, I would like to be able to send to my app the same data as for 1, and I cannot add it to the URL (the payload is too large). The issue is that I can only use
Client.postMessage when my app is ready to receive such messages…
What is the simplest way to do that?
Note: my use case is a chat app for which a push notification is displayed when a message is received and a click on the notification triggers the app and shows the corresponding chat and message. I want to pass the content of the message itself (which is in the push notification received by the service worker) to the app so it can show directly, instead of having to pull it from the backend.
This is how I solved the problem: