1
votes

I'm working with @angular/service-worker.

I don't know how to handle push and notificationclick events. Does anyone know a way to extend the service worker autogenerated by Angular (ngsw-worker.js)?

I've found an issue related with this question. Does anyone know if there is any workaround at the moment?

Thanks.

1
Hi, welcome to stack overflow. Please refer the How to Ask link for more details on how to ask a question and update your question accordingly.Jeroen Heier
@Juanlu Did you get any solution for this. I am facing the same problem. ThanksSampat
@Sampat Sorry, I haven't found any solution yet.Juanlu
@Juanlu Any updates on this? Even if the question violates the How to Ask, it is a valid question. Have you been able to do this? I need this now for an implement. Raised an bounty if you wish to answer here. stackoverflow.com/questions/50127438/…Gary

1 Answers

2
votes

This answer can be a bit late but maybe it still being useful to you and maybe to others. I faced a similar issue and the way I solved it was by using a second service worker. A domain can serve more than one service worker you just need to guarantee that they have different scopes. You define the scope when registering the service worker:

navigator.serviceWorker.register('secondServiceWorker_20181223.js', 
                        { scope: '/anyScope/' })

Btw, you should also register your new service worker in your Index.html and in your angular.json under the assets key. And don't forget to add something to the filename that will allow you change and bust the cache on the client side when you need to update the service worker version. Hope it helps ;)