Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FR: Focus tab of the same origin (but not with the same url) #390

Closed
Oupsla opened this issue Dec 19, 2017 · 8 comments · Fixed by #2772
Closed

FR: Focus tab of the same origin (but not with the same url) #390

Oupsla opened this issue Dec 19, 2017 · 8 comments · Fixed by #2772

Comments

@Oupsla
Copy link
Contributor

Oupsla commented Dec 19, 2017

[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:

  1. Integrate the firebase-js-sdk into an application
    1.b. Navigate into the application
  2. Send a push notification to a client (with a click_action in the payload)
  3. Click on this notification
  4. See that will open a new tab (or window)

Relevant code :

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

@karooolis
Copy link

karooolis commented Sep 3, 2019

I would like to take this on as it's currently affecting our project forcing to workaround it by making use of setBackgroundMessageHandler and custom notificationclick event handler. Is this worth working on or there is no intention of doing any changes here, at least as of yet?

@VapiSoft
Copy link

Did you find any solution to this huge problem?

@Oupsla
Copy link
Contributor Author

Oupsla commented Mar 20, 2020

I think it could be easily resolved, instead of the equal operator (here), we could use an include instead

I will make a PR with that 🙂

----- Edit

Done 😄

@VapiSoft
Copy link

VapiSoft commented Mar 20, 2020 via email

@Oupsla
Copy link
Contributor Author

Oupsla commented Mar 20, 2020

I have made the pull request, waiting for maintainers to review 🙂

@VapiSoft
Copy link

VapiSoft commented Mar 20, 2020 via email

@VapiSoft
Copy link

VapiSoft commented Mar 20, 2020 via email

@zwu52 zwu52 assigned zwu52 and unassigned zwu52 Apr 14, 2020
@VapiSoft
Copy link

VapiSoft commented Apr 22, 2020 via email

@firebase firebase locked and limited conversation to collaborators May 22, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.