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

Web Push userVisibleOnly Details #30077

Closed
aluhrs13 opened this issue Nov 6, 2023 · 7 comments
Closed

Web Push userVisibleOnly Details #30077

aluhrs13 opened this issue Nov 6, 2023 · 7 comments
Labels
Content:PWA Progressive Web Apps content Content:WebAPI Web API docs effort: small This task is a small effort. goal: accuracy (Experimental label) Issues about inaccurate/incorrect content. goal: clarity (Experimental label) Issues about unclear/confusing/inconcise content.

Comments

@aluhrs13
Copy link

aluhrs13 commented Nov 6, 2023

MDN URL

https://developer.mozilla.org/en-US/docs/Web/API/PushSubscriptionOptions/userVisibleOnly

What specific section or headline is this issue about?

No response

What information was incorrect, unhelpful, or incomplete?

The Push API spec includes a userVisibleOnly option, that MDN implies is fully functional for WebKit or Chromium browsers but isn't actually the case. Both will reject the promise requiring it to be true.

Normally an API predictably rejecting a promise isn't a huge deal, but if a developer goes through the overhead of understanding applicationServerKey, VAPID, push services, etc. only to see "Promise Rejected", that could be extremely frustrating.

At a minimum it seems like the page PushSubscription options should include details on this, but the following pages could probably use more aggressive dissuading developers from trying to use push for non-visible cases:

  1. https://developer.mozilla.org/en-US/docs/Web/API/PushManager/subscribe#syntax
  2. https://developer.mozilla.org/en-US/docs/Web/API/Push_API
  3. https://developer.mozilla.org/en-US/docs/Web/Progressive_web_apps/Tutorials/js13kGames/Re-engageable_Notifications_Push

For completeness, I could I only find one page online calling out this behavior - https://web.dev/articles/push-notifications-subscribing-a-user#uservisibleonly_options

What did you expect to see?

That browsers might reject a subscription if userVisibleOnly is set to false. Happy to open an issue and/or PR on the browser-compat-data side if that's the best place to approach this too.

Do you have any supporting links, references, or citations?

Do you have anything more you want to share?

No response

@aluhrs13 aluhrs13 added the needs triage Triage needed by staff and/or partners. Automatically applied when an issue is opened. label Nov 6, 2023
@github-actions github-actions bot added Content:PWA Progressive Web Apps content Content:WebAPI Web API docs labels Nov 6, 2023
@caugner
Copy link
Contributor

caugner commented Nov 8, 2023

The read-only userVisibleOnly property on the PushSubscriptionOptions object seems to be supported in Chrome 54+, Edge 17+, Opera 41+ and partially supported in Safari 16+, according to BCD.

You're saying that browsers reject a subscription if userVisibleOnly is set to false, but this page seems to be about being able to read this property.

It looks like the userVisibleOnly property can only be set on the PushSubscriptionOptionsInit dictionary, which isn't explicitly documented on MDN, but covered by the PushManager.subscribe() article.

I agree that the definition of userVisibleOnly on that page could mention that the value must be set to true in practice, even though the specification doesn't mention this requirement.

@caugner caugner added effort: small This task is a small effort. goal: clarity (Experimental label) Issues about unclear/confusing/inconcise content. goal: accuracy (Experimental label) Issues about inaccurate/incorrect content. and removed needs triage Triage needed by staff and/or partners. Automatically applied when an issue is opened. labels Nov 8, 2023
@aluhrs13
Copy link
Author

@caugner Yep, my bad on the wrong page, mixed up the pages when I had so many open, PushManager.subscribe() is the most correct.

@Ryuno-Ki
Copy link
Collaborator

I learned about this issue on Mastodon because @captainbrosset tooted about it.

When trying the demo at https://attractive-tranquil-nephew.glitch.me/ I cannot reproduce the behaviour in Firefox 115.0.2 on Debian/Linux. Nevertheless I would be willing to submit a PR that addresses this:

It looks like the userVisibleOnly property can only be set on the PushSubscriptionOptionsInit dictionary, which isn't explicitly documented on MDN, but covered by the PushManager.subscribe() article.

I agree that the definition of userVisibleOnly on that page could mention that the value must be set to true in practice, even though the specification doesn't mention this requirement.

@captainbrosset
Copy link
Contributor

The error message seems to be displayed on Chromium-based browsers (in the Console panel of DevTools). Nothing seems to happen in Firefox.

@Ryuno-Ki
Copy link
Collaborator

Confirmed (as in: Promise rejected logged to the console) with Chromium Version 119.0.6045.159 (Official Build) built on Debian 12.2, running on Debian (64-bit).

@Ryuno-Ki
Copy link
Collaborator

I've submitted #30369 and checked the other MDN pages. As far as I can tell, the property is always set to true there.

@Josh-Cena
Copy link
Member

I think this is sufficiently fixed by #30369

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Content:PWA Progressive Web Apps content Content:WebAPI Web API docs effort: small This task is a small effort. goal: accuracy (Experimental label) Issues about inaccurate/incorrect content. goal: clarity (Experimental label) Issues about unclear/confusing/inconcise content.
Projects
Archived in project
Development

No branches or pull requests

5 participants