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: Support webpush.fcm_options.link for opening another domain. #5822

Open
rockmandash opened this issue Dec 17, 2021 · 1 comment
Open

Comments

@rockmandash
Copy link

[REQUIRED] Describe your environment

  • Operating System version: macOS 12.0.1
  • Browser version: Chrome 96
  • Firebase SDK version: 9.6.1
  • Firebase Product: cloud messaging

[REQUIRED] Describe the problem

According to the code below, when a user clicks the notification from FCM, it can only open the same domain.

// FM should only open/focus links from app's origin.
const url = new URL(link, self.location.href);
const originUrl = new URL(self.location.origin);
if (url.host !== originUrl.host) {
return;
}

It would be fantastic if we could open a URL from another domain.

For the time being, I've devised a workaround: directly above the call to firebase.messaging(), insert your own notificationclick:

self.addEventListener('notificationclick', event => {
  const url = event.notification.data.FCM_MSG.notification.click_action
  
  clients.openWindow(url)
})

firebase.messaging()

It is necessary to install an event listener sooner rather than later since it will be halted by the following line:

event.stopImmediatePropagation();
event.notification.close();

@guimap
Copy link

guimap commented May 13, 2022

Up for this current thread, I'm having this same issue :/
There's any update ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants