Open mkruisselbrink opened 8 months ago
I think if the user agent wants, they can show the required permission prompt when the app tries to set a badge, so websites shouldn't need to worry about requesting the permission separately. Was that what we intended here @marcoscaceres? Sounds like it might be worth cleaning up anyway
For an API like this (which might be called in contexts where permission prompts can't be shown like service workers, or without user interaction) generally the user agent automatically showing a permission prompt doesn't work very well. Although it is one thing I am considering maybe doing. It would at least be better than user agent sniffing or unconditionally requesting permission...
unconditionally requesting permission...
This is what the demo does now unfortunately.
Good point @mkruisselbrink - I've clearly been out of it for a while :laughing:
Hmm, definitely feels unideal that the demo is unconditionally requesting permission to show notifications - Is it a requirement now, that the notifications permission is granted?
It's a requirement in Safari, and it might become a requirement in Chrome on MacOS (for the same OS reasons that it is a requirement in Safari I imagine).
In step 4.2 of the setting the application badge algorithm, it is written that if a user agent requires express permission (and notifications permission hasn't been granted), they should jected with a NotAllowedError. As far as I know this isn't implemented by at least the one user agent I'm aware of that has this permission requirement (i.e. webkit), as both Navigator.setAppBadge and the equivelent WorkerNavigator code unconditionally resolve the returned promise with undefined.
But without that promise rejection, I'm not sure how websites are supposed to determine if they are required to request notifications permission in order to use app badging. Are we expecting site authors to do user agent sniffing (and try to come up with a complete list of user agents that have this requirement)? Should there perhaps be a separate "is notifications permission required for app badging" API? And if there are no user agents that actually implement step 4.2, should the step even exist in the algorithm?