w3c / push-api

Push API
https://w3c.github.io/push-api/
Other
144 stars 40 forks source link

Mention or enforce userVisibleOnly check in PushManager.subscribe? #339

Open youennf opened 2 years ago

youennf commented 2 years ago

After some testing, it seems that both Chrome and Firefox are disallowing calling PushManager.subscribe with https://w3c.github.io/push-api/#dom-pushsubscriptionoptions-uservisibleonly not present or set to false. It would be good to indicate this possibility in the specification, for instance as a guideline, or directly within the subscribe algorithm directly.

marcoscaceres commented 2 years ago

We should also mention what's described in MDN:

Activating a service worker to deliver a push message can result in increased resource usage, particularly of the battery. Different browsers have different schemes for handling this, there is currently no standard mechanism. Firefox allows a limited number (quota) of push messages to be sent to an application, although Push messages that generate notifications are exempt from this limit. The limit is refreshed each time the site is visited. In Chrome there are no limits.

In particular, we should describe that the UA can take action if a push "event" is received and, for example, no notification is shown (c.f. the subscription might get cancelled, as is the case in Safari I think).

aarongustafson commented 2 years ago

the subscription might get cancelled, as is the case in Safari

@marcoscaceres To clarify, are you saying that when a "push" event listener within a Service Worker is triggered in Safari and the listener does not include a call to showNotification(), the subscription will be automatically destroyed?