Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Provide means to configure notificationclick in service-worker push #20956
I'm submitting a...
When a PushNotification is received by the ServiceWorker, I want to be able to handle the notificationclick event. For instance open the webapp and navigate based on the data that was passed in in the PushNotification
Minimal reproduction of the problem with instructions
What is the motivation / use case for changing the behavior?
There is a workaround.
Then you can specify the URL in the "notification.data.url".
referenced this issue
Mar 19, 2018
I've played around a little with the service-worker code and came up with a solution of extending existing service worker with a notificationclick listener. Can anyone provide some other use-cases of this eventlistener except for redirecting the user to specific url ?
As the browser support is kind of poor as of right now, see https://developer.mozilla.org/en-US/docs/Web/API/Notification (actions array is supported only in Opera and Chrome).
@sinasava you can probably extend the generated ngsw.js with your code, which would receive a message from application with definition of the function that should handle the notification click, it is fairly easy to implement. The next step would be to tell angular to look for your extended ngsw instead of using the generated one.