GoogleChromeLabs / web-push-codelab

Other
557 stars 293 forks source link

notificationclick don't check for opened tabs #18

Closed jpenna closed 7 years ago

jpenna commented 7 years ago

The notificationclick method is said to check for opened tabs and only open a new tab if the URL isn't already open. It isn't working like this. Even if I have the tab opened, clicking the push open a new tab on the same URL again.

From the tutorial:

"This code checks all window clients for this Service Worker; if the requested URL is already open in a tab, focus on it — otherwise open a new tab for it."

gauntface commented 7 years ago

This is a bug in the codelab.

The list of window clients will only return windows that are for the same domain as the website subscribing for push, this prevents snooping on what users are viewing.

This will be fixed in: #17

I've also jotted down some more info here: https://web-push-book.gauntface.com/chapter-05/04-common-notification-patterns/#focus-an-existing-window

jpenna commented 7 years ago

Cool! Thanks for the explanation