-
Notifications
You must be signed in to change notification settings - Fork 162
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
Way to detect if a web app is installed #1092
Comments
Previously #273 |
This is the first I'm hearing of Q: Is there a difference between I would prefer to have some way to express that as a CSS MQ. I seem to be able to express it using
I don't follow this (also, which spec?). If you use |
Note from chatting with Marcos: Yes it basically is dm: fullscreen is true when you're in the browser but fullscreen mode. But Further discussion: Ideally such a thing would be itself a new MQ, not a JavaScript Boolean with somewhat the wrong name. So we can design a new MQ for it. But that aside, should we just standardize Matt will ask around internally to see if we have seen compat issues due to a lack of |
Having a corresponding media feature/query would be great, particularly given the use case is generally to control the web page's UI (generally to take away install buttons and instructions). It could be as simple as ( |
FWIW, it's been something iOS-focused web developers have depended upon and expected to be in Chrome DevTools' iOS device simulation mode, so I filed crbug/1197498 some time ago. I'm not opposed to standardizing it as a legacy feature. The future is definitely non-ambiguous media queries where you can exactly express what you want to test for, which is why I created the WebKit bug. If WebKit decides to report it, there should probably a differentiation between navigation controls on (corresponds to |
Update here. Standardizing What happened?Mozilla to detect the iPad Pro was using So Safari 17 Desktop with Mozilla fixed it. So this is to keep in mind in the solutions that needs to be evaluated. |
One potential difference here, if you want an "is this installed" bit, is that display mode css media query is spec'd to be the current display mode, which includes 'fullscreen'. So if you have an installed app that you go fullscreen, then it'll be "standalone" -> "fullscreen" -> "standalone" (when you exit fullscreen). This seems to really confuse developers, so I propose we have a signal that is something like "is this URL within scope of an installed app" signal (this allows it to work with Safari & Chrome's different implementations of isolation). |
@dmurph, that's an interesting re-interpretation and might work. However, when you say "This seems to really confuse developers", what is "this" exactly? Can you clarify a bit? |
Reminder: there's a lengthy discussion of an “installed” signal on the App Info spec: w3c/manifest-app-info#42 There is also the Client Hint for display modes proposal too (though that's more server side). Of course I'm also still super skeptical about the wisdom in relying on display modes as an indication of installation. I'd much prefer an explicit signal that you are, in fact, viewing the site in it's installed state (hence the discussion above). I'm not entirely sure what's to be gained from having this. I'm not deadset against it, I guess I'm just not convinced of the value yet. |
Discussing with @dmurph, as an alternative:
And we keep the legacy:
As WebKit/Safari Web Apps are fully isolated (they are an entirely different user agent), there is no way of sharing "is this web app installed". For a site in a browser to know if a web app is (or was) installed would break the privacy model of Safari. |
I can understand how, when compared to the web overall, this would be an issue, but this is not something shared by apps developed in Swift, even those that make use of the web view, right? I'm also curious to know what Apple's specific privacy concerns are, especially if the check only applied specifically within the context of the installed app and not in a casual browsing (e.g., browser tab) scenario. |
Action here is to float this with the CSS Working Group. You say "installed" in cases where you wouldn't want to show an install button... has the user "installed" this web application. Only applies to top-level navigable. This can't apply cross origin. Cross-origin must return false (or "no"). |
Feedback here: https://issues.chromium.org/issues/331692948#comment15
This is supportive evidence for an 'installed' attribute that can be media-queried. |
Also interested in thoughts from folks on this doc: https://bit.ly/pwa-detecting-install |
It's impossible to know if our app is running as a PWA when using Chrome Enterprise Kiosk & Signage, which is really impactful because Chrome Enterprise Kiosk doesn't allow users to open external links at all. We need to handle this, but there's no way to detect if our app is running as a PWA in Chrome Enterprise Kiosk. |
Hey @tomayac or @reillyeon, can you please see #1092 (comment) ... it's a bit out of scope for this repo, but maybe a quick response to the above? |
This looks more like a Chrome feature request than something we'd want to discuss in the manifest spec repository. Could you open a new Chrome bug for this, please? |
@tomayac Chrome team sent us here |
I'm not sure what Chrome Enterprise does exactly in kiosk mode. The usual flow would be to chck |
@tomayac Chrome Enterprise behaves exactly like regular Chrome, except Chrome Enterprise cannot open external links in kiosk mode. In both cases, it is impossible to determine if an app is running as a PWA when fullscreen is enabled (which is always the case "fullscreen" in Chrome Enterprise Kiosk). When Chrome Enterprise Kiosk runs a PWA, a regular browser page in fullscreen mode, or a PWA on Chrome, all return check this comment: https://issues.chromium.org/issues/331692948#comment4 |
I believe, from TPAC, we are in agreement on: where (although, to bikeshed, should we do |
Discussed with @dmurph, let's stick to "installed". |
AI Generated based on what we discussed: Explainer: Standardizing and Implementing Web Application Context DetectionOverviewThis feature standardizes the terminology and mechanism to detect whether a web application is operating in an "installed-like" context (e.g., launched as a standalone app, added to a home screen). The goal is to replace the ambiguous term "installed" with a clear and developer-friendly alternative while aligning browser implementations and specifications. Problem StatementWeb applications often operate in different contexts, such as:
Currently, developers rely on terms like "installed," which are inconsistently defined across platforms. This ambiguity leads to challenges in building cohesive user experiences. Proposed SolutionStandardize the terminology and introduce clear mechanisms to detect and respond to a web app's context. The proposed term (e.g., "Standalone Mode", "PWA Mode") will be applied consistently in the Web App Manifest specification, browser implementations, and developer tools. Feature Goals
How It WorksTerminologyWe propose replacing "installed" with:
Media Query ExampleThe @media (display-mode: standalone) {
body {
background: #f0f0f0;
}
} API ExampleA new property or method can provide a programmatic way to check the app's context: if (navigator.standalone) {
console.log('The app is running in Standalone Mode!');
} User ExperienceFor end-users, this change is seamless. Developers gain better tools to optimize user experiences across contexts. Implementation PhasesPhase 1: Specification Updates
Phase 2: Implementation in WebKit
Phase 3: Alignment with Chromium
Phase 4: Developer Outreach
Benefits
Next Steps
By standardizing this terminology and implementation, we can make the web platform more robust, predictable, and developer-friendly. |
another version from AI that likely has weird problems: Detecting Installed Web Apps: A New CSS Media Query and PropertyDevelopers have long requested a reliable way to detect if a web app is installed on a user's device. This is important for tailoring the user experience, such as hiding install prompts or providing app-specific features. A new CSS media query and JavaScript property are being introduced to address this need and overcome limitations with existing methods. The New Features:
Use Cases:This feature addresses several crucial use cases:
Benefits:
Next Steps:The proposal is currently being discussed within the W3C Web Apps Working Group and will be implemented in major browsers like WebKit and Chromium. This collaboration aims to create a consistent and reliable way for developers to detect and respond to the context of their web applications. |
I just wanted to highlight that there are two orthogonal states of a web application which are being discussed here:
Installed web apps can use any display mode, currently including:
For the former I support the term "installed" being used because that is the term used by native applications on most operating systems and if the intention is for web apps to be treated as first class citizens then that should be reflected in the language used in CSS selectors and the DOM. For the latter, the term used in the specification is "display mode", of which "standalone" is only one. Therefore I would suggest a key (whether a CSS selector or DOM property) of Note that because deep linking is not widely implemented, it's possible for a URL within the navigation scope of an installed web app with a As an aside, may I politely suggest that the raw output of LLMs is not copy-pasted as a contribution in standards discussions? I wasted a lot of time reading the word spaghetti above in my email notifications before clicking through to the edited version on GitHub which discloses that it was generated by "AI" and not a human contributor. |
@benfrancis wrote:
Good to think about. We're planning on shipping something like this soon in Chrome (chrome://flags/#enable-user-navigation-capturing-pwa, reimpl option). However - the 'browser' installed mode doesn't have cross-engine consensus here. I think moving forward here with the current proposal, interpreted as 'this is displayed in an installed / standalone window' solves the immediate use-cases here around the display-mode + 'fullscreen' resolution problems. 'installed' might not be the best best name... 'standalone' seems more correct but it's already way too overloaded a term. So 'installed' seems good enough. This doesn't block us from adding more media queries / values on the Chromium side to expose the 'installed but in the browser' mode in the future. If there is a request for that we can certainly look into it - but I don't think there is (at this point) cross-engine consensus on that yet. So I'd like to move forward with the proposal of the css media query and the navigator.standalone property. |
@dmurph wrote:
Cool to know you're experimenting with this in Chrome! I'm interested to see how that works given your presentation on all the tricky edge cases.
To be clear, what exactly is the current proposal? There were two proposals pasted above that were generated by large language models, but neither made sense to me. What would the keys and possible values of a CSS media query and DOM property be and what do they mean? E.g. If a web app is installed with a display mode of Even if you ignore the browser display mode, "standalone" is currently the name of one of three "display modes", all of which could be used by an "installed" app. |
The meaning is that the web contents is in an app window. @marcoscaceres we should clarify what frames can see this. I think navigator.standalone is only top level? I'm embarrassingly ignorant of the iframe terminology, but I think there is a concept of a more trusted iframe vs a less trusted one, and I would hope that these are populated for the trusted but not the untrusted. |
What do you have in mind as the definition of an "app window"? This could imply a number of things... like whether the app appears in the OS list of installed applications, whether it has its own icon on the taskbar/dock, whether it has an address bar visible, whether it's scoped to a particular domain, whether it's acting on a PWA manifest, and probably more. Each browser could offer one more configurations that might be described as an "app window" and the site developer won't know (or will assume and be wrong about) what it means. I think instead we should offer information on the mode a site is running in and the capabilities available to it on a feature-by-feature basis, at the level of granularity that is relevant to users and the site. |
@drubino-mozilla wrote:
@dmurph Would I be right to assume that "app window" is a less formal term for "application context", or at least a UI element which contains an application context? "A top-level browsing context that has a manifest applied to it is referred to as an application context." (section 1.16.5 of the specification) This is independent of any kind of UI design. On Android and iOS I think it's fairly obvious because the application context is presented as a separate application window in the window switcher with its own icon, separate from the browser application. You're either in the browser app or you're in a separate app. In the implementation I'm working on it's more fluid that that. Users can deep link in and out of different applications using the same browsing context. When they navigate to a URL inside the navigation scope of an installed app, the manifest is dynamically applied to the browsing context to create an application context. Then if they navigate outside the scope of the app the manifest is un-applied, or a different manifest is applied. Things a developer might want to know are whether the app is installed (e.g. to stop suggesting the user install the app) and what the current display mode is (e.g. to subtly modify the UI design in fullscreen display mode), but I don't think these two things should be conflated (which is why "navigator.standalone" is a potentially confusing name). BTW you also can't assume that the display mode defined in the manifest is the display mode used by the user agent when launching an app, because all display modes are optional for user agents to implement and they have a fallback chain. |
The
navigator.standalone
attribute has been in iOS since forever and has the nice semantics in that, as a boolean value, it distinguishes between installed web applications and those running in the regular browser tab.It's slightly unfortunate that "standalone" will mean "installed" (as per the spec's definition), and there is also "display-mode: standalone", but I think that's ok.
What do folks here think? @dmurph, @aarongustafson, would love to hear your thoughts!
See also this webkit bug.
The text was updated successfully, but these errors were encountered: