Summary: | Push notifications with same tag do not replace each other | ||||||
---|---|---|---|---|---|---|---|
Product: | WebKit | Reporter: | ekzyis <ek> | ||||
Component: | Service Workers | Assignee: | Brady Eidson <beidson> | ||||
Status: | NEW --- | ||||||
Severity: | Normal | CC: | beidson, ik, mrigbyjones, nham, thomas, webkit-bug-importer, wilkinson | ||||
Priority: | P2 | Keywords: | InRadar | ||||
Version: | Safari 16 | ||||||
Hardware: | Unspecified | ||||||
OS: | iOS 16 | ||||||
Attachments: |
|
Description
ekzyis
2023-07-06 05:54:48 PDT
Created attachment 466943 [details]
notifications with same tag do not replace each other
We don't support tag yet, but we can use this bug to track the feature request. We might dup this to an existing bug tracking the same work (which I think exists, but I can't find it right now). To be clear: the tag attribute on Notification is exposed. You can set it via the Notification constructor/ServiceWorkerRegistration.showNotification and access its value later on. But the browser currently doesn't use the property to coalesce notifications. That will require additional work. Ah, I see. Thanks for your fast reply and clarification! I created a ticket for MDN to update their support declaration until this feature is supported: https://github.com/mdn/browser-compat-data/issues/20305 Any ETA on when this will be supported? An additional data point: this appears to be partially working on macOS Safari. While a second notification with the same tag appears as a new entry in the system notification center, it does replace an existing one in the array returned by ServiceWorkerRegistration.getNotifications(), and a notificationclose event is fired for the old/replaced notification. (For comparison, macOS Chrome replaces the notification in both places, and does not fire a notificationclose event for the replaced notification.) On iOS Safari, ServiceWorkerRegistration.getNotifications() appears to always return an empty array, so there's no way to compare that behaviour. Do we have an estimate of when this will be supported? Hey, I finally managed to get access to an iPhone running iOS 17.1 so I could debug this on Safari now. I have noticed following things: 1. Notification.close() doesn't work. It seems to do nothing even though MDN says it's fully supported on Safari since 16.4. MDN only says that the 'close' event is not supported but that should be independent, no? [0, 1] 2. Contrary to this comment [2], ServiceWorkerRegistration.getNotifications() does return an array. It seems to correctly return the notifications that are currently displayed to the user. If a notification is swiped away, the next call to getNotifications() reflects that. 3. There is a 'onPush' race condition. If push notifications are received too fast, some calls receive a stale value from getNotifications(). For example, if you send 5 push notifications, the first two might see an empty array returned from getNotifications, while the next 3 push notifications receive an array of size 2. This is not the case on Android. A detailed analysis can be found here: https://github.com/stackernews/stacker.news/issues/411#issuecomment-1882137442 Currently, we would be happy if we at least could close notifications in some way and if this is reflected by getNotifications(). Is that possible somehow? [0] https://developer.mozilla.org/en-US/docs/Web/API/Notification/close [1] https://developer.mozilla.org/en-US/docs/Web/API/Notification/close_event [2] https://bugs.webkit.org/show_bug.cgi?id=258922#c6 Regarding c#8 2): getNotifications() always returned an empty array until a later 16.x release. It has since been fixed and now returns the correct number of notifications - except if you try to replace a notification with `tag`, then you end up with two notifications but getNotifications() returns 1. The current implementation of the Web Push / notification API in WebKit is incomplete but DOES pass tests, so sites that do proper feature detection will end up with unexpected behaviour. Also, web developers will expect these things to work as MDN indicates they are supported (again, because the tests pass). Please prioritize fixing these problems. Web Push on iOS has been "implemented but incomplete" for almost a year now (feb 2023). hi, can you share if there's been any progress with the bug? |