I'm trying to implement Firebase Cloud Messaging in a web-app (with Polymer and a service-worker and using the custom-sw of the SDK).
It is working great (on both desktop and android) but when the user click on the notification it is always opening the click_action
in a new tab even if a tab of the same origin is opened (but not focused).
click_action = "https://example.firebaseapp.com/demo/command"
Url of inactive tab = "https://example.firebaseapp.com/demo"
It seems that the getWindowClient_
method of the FCM SDK is not parsing correctly the URL of active clients and so can't call focus()
on the inactive tab.
Any idea how to resolve this ?
That is how it is designed. It caught me off guard at first, but after I thought about it, the new tab/window made sense.
1) the service worker is a separate process from the browser. 2) when a notification displays it is not associated with a browser tab/window. 3) changing the url in an existing window would most likely confuse/irritate the user.
When the user clicks your button the notification assumes no active tab on the origin. So it opens a new window.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With