-
Notifications
You must be signed in to change notification settings - Fork 985
Description
[REQUIRED] Describe your environment
- Operating System version: Ubuntu 16.04 / Chrome 63 / Node 8.9
- Firebase SDK version: 4.8.1
- Firebase Product: messaging
[REQUIRED] Describe the problem
When receiving a push message with a click_action in the notification payload, the service-worker tries to find a tab with the same url than the click_action.
If it succeeds, the service worker focus this tab.
If it fails, the service worker opens a new tab (or window).
But the url of the tab has to be exactly the same url than the click_action.
If a tab with the same origin than the click_action but with a different url (a different page, for my case in a one page application with Polymer) is found, the service worker will open a new tab instead of focusing this tab and send a message to it (to tell the application to change the page for example).
Steps to reproduce:
- Integrate the firebase-js-sdk into an application
1.b. Navigate into the application - Send a push notification to a client (with a click_action in the payload)
- Click on this notification
- See that will open a new tab (or window)
Relevant code :
getWindowClient_(url) {
| getWindowClient_(url) { |
Example
Notification payload:
{ notification: { 'title': 'Title', 'body': 'Message body', 'click_action': 'https://example.firebaseapp.com/demo/commands/' } }
Url of the inactive tab : https://example.firebaseapp.com/demo