-
Notifications
You must be signed in to change notification settings - Fork 62
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
Home screen installation is available in Firefox Android and UC browser #36
Comments
Well I don't know how to handle this one correctly yet. First is that technically speaking, all browsers have the "create link" feature available somewhere deep in the menu (incl. Safari). So maybe I should put a green tick everywhere. But maybe I should distinguish the "proper" support, that somehow advertizes/prompts the user if the site has a proper manifest. Chrome-like prompts are one option, but Samsung Internet has another kind of icon for manifest-enabled pages - that should probably be sufficient. Or maybe "proper" is only the approach with WebAPK that lets the app get rid of the "shortcut" badge and makes the PWA a first-class citizen? I'm not sure. The other thing is that it's hard to detect the level of support without browser sniffing that I don't want to do. Right now the tick is based on |
Screenshot of UC support https://twitter.com/nekrtemplar/status/938727117436735489?s=17 |
I gave it a bit more thought and ideally I think I should detect a support for I can detect if the browser understands this media query at all, but it's far from being ideal. Safari will be ❌ but all the desktop browsers (including Safari Technology Preview) will be ✔️ - and this is incorrect if we want to answer the question "does this browser is able to create a thing on my home screen". What I should be detecting is whether the browser is able to actually use |
Maybe use @supports (display-mode: standalone) {
.throw-away {
color: rebeccapurple;
}
} …and then… if (window.getComputedStyle(document.querySelector('.throw-away')).color === 'rebeccapurple') {
// A2HS supported
} Not sure if the |
Thanks @tomayac. I explored this route too, but from what I can see it is only able to determine if the browser IS in standalone mode. What I want to determine is if the browser IS ABLE TO actually enter this mode. What I did was: let style = document.createElement('style')
document.getElementsByTagName('body')[0].appendChild(style)
style.innerText = '@media (display-mode: standalone) {}}'
let result = document.styleSheets[document.styleSheets.length - 1].cssRules[0].media.mediaText If the But, for instance, it will still succeed in Chrome on desktop, where we have no meaningful A2HS available. |
Well, technically, there is the concept of |
Check if the browser understands Web App Manifests as the universally agreed-on requirement for add to home screen: document.createElement('link').relList.supports('manifest') |
Nice one @tomayac ! |
Yes, this is neat. Although I still have some doubts what a "support for add to home screen" means. Excerpts from the Web App Manifest spec On the one hand we have:
Reading this it seems like any way of putting a link/shortcut on the home screen qualifies as an installation. UC fulfils this for sure, Samsung Internet, too. Although we can also read that:
UC Browser does not apply any manifest-defined theming when I open the link from the home screen. It does not use In the installation algorithm we can also read that:
So we might check for |
FWIW, I settled with this solution for PWA Feature Detector: document.createElement('link').relList.supports('manifest') &&
'onbeforeinstallprompt' in window This makes sure the browser understands what a Web App Manifest is, and has at least the theoretical ability to trigger a prompt. The event is well-documented and in the spec. One could go one step further and even check for onappinstalled, but I don't think this would add much value. |
@tomayac So you've ended up with the solution that rejects both Firefox Android and UC Browser, the ones you've started the discussion with? I've opened your detector with Firefox Android and it proposed me to add to home screen even though you are displaying red cross there. So you're now aligned with What Web Can Do Today 😉. And we're both wrong in a sense. |
I guess you’re right in your observation, yes. I feel like right now there’s just no one right or wrong approach, more an approximation of what one personally considers a valid “add to home screen”. The spec also (on purpose it seems) is pretty vague as to the when and how a prompt should trigger. |
Home screen installation is available in Firefox Android and UC browser
The text was updated successfully, but these errors were encountered: