How do I handle the push notification click in angular service worker. The SWPush does not have any methods.
I have tried referencing a js which listens to the "notificationclick" event handler but it never got fired on the click of the notification button.
I had to update my package.json to:
"@angular/service-worker": "7.1.0"
then this worked for me:
Call SWPush#requestSubscription. Here's a good article
I suggest to update angular to at least Angular version 7.1.0 ( I would suggest to maintain up to date ). With this, you can now subscribe to
notificationClicks
In the constructor inject
SwPush
then use it with:If you don't want to update you should watch the file
ngsw-worker.js
withWebpack
orgulp
or etc. And then after the line withthis.scope.addEventListener('push', (event) => this.onPush(event));
add the following: