I'm trying to implement both ServiceWorkers, but since we can't have two SW registered, I'm having a bit of a problem.
I am following this article: https://pusher.com/docs/beams/guides/existing-service-worker/
But the problem is that Angular's SW can change and we should not update it's source. Because of that, I can't add anything into it. So I'm wondering, how can I combine Angular's SW with your SW?
My current implementation idea was to ignore the PUsher's SW, but still register the BeamsClient. This way I can receive notifications, but if I tap/click on it, it does not open a browser with provided URL.
I then tried to manually send the Push notification from Chrome's Developer Console and if I structure them correctly, then everything works. But apparently when I send the same data through your network, it strips out the data attribute, so the click action again does not work.
This is a working example of the data that works:
{
"notification": {
"title": "Test notification",
"body": "A longer description of the notification",
"icon": "... a valid URL to the icon ...",
"deep_link": "... relative URL ...",
"data": {
"onActionClick": {
"default": {
"operation": "openWindow",
"url": "/just-some-random-url/123"
}
}
}
}
}
But your network converts it into this:
{
"notification": {
"title": "Test notification",
"body": "A longer description of the notification",
"icon": "... a valid URL to the icon ...",
"deep_link": "... relative URL ...",
}
}
Notice the missing data attribute. Because of this, when tapping or clicking on the notification, URL is not being opened.
I also tested by moving the data out of notification, like:
{
"notification": {
"title": "Test notification",
"body": "A longer description of the notification",
"icon": "... a valid URL to the icon ...",
"deep_link": "... relative URL ..."
},
"data": {
"onActionClick": {
"default": {
"operation": "openWindow",
"url": "/just-some-random-url/123"
}
}
}
}
Also doesn't work, because Angular's ServiceWorker does not support this format.
So, how to make this one working properly? Please note that I am using Angular with PWA module, where Service Worker is already installed. I'm using Angular v14.
I'm trying to implement both ServiceWorkers, but since we can't have two SW registered, I'm having a bit of a problem.
I am following this article: https://pusher.com/docs/beams/guides/existing-service-worker/
But the problem is that Angular's SW can change and we should not update it's source. Because of that, I can't add anything into it. So I'm wondering, how can I combine Angular's SW with your SW?
My current implementation idea was to ignore the PUsher's SW, but still register the BeamsClient. This way I can receive notifications, but if I tap/click on it, it does not open a browser with provided URL.
I then tried to manually send the Push notification from Chrome's Developer Console and if I structure them correctly, then everything works. But apparently when I send the same data through your network, it strips out the
dataattribute, so the click action again does not work.This is a working example of the data that works:
But your network converts it into this:
Notice the missing
dataattribute. Because of this, when tapping or clicking on the notification, URL is not being opened.I also tested by moving the
dataout ofnotification, like:Also doesn't work, because Angular's ServiceWorker does not support this format.
So, how to make this one working properly? Please note that I am using Angular with PWA module, where Service Worker is already installed. I'm using Angular v14.