From a96f936ed57202cb5e0a3c49786fd5a3730ca538 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Marcos=20C=C3=A1ceres?=
- There are multiple ways that the installation process can be
- triggered:
-
- In any case, the user agent MUST NOT present an install prompt
- if the document is not installable.
-
- Prior to presenting an automated install prompt, a user agent
- MUST run the steps to notify that an install prompt is
- available, to give the site the opportunity to prevent the
- default action (which is to install the application). Alternatively,
- the user agent MAY, at any time (only if the document is
- installable), run the steps to notify that an install
- prompt is available at any time, giving the site the opportunity
- to show a site-triggered install prompt without automatically
- showing the prompt.
-
- To present
- an install prompt:
-
- The steps to notify that an install prompt is available
- are given by the following algorithm:
-
- During the presentation of the install prompt, it is
- RECOMMENDED that the user agent allow the end-user to inspect the
- icon, name, start URL, origin, etc. pertaining to a web
- application. This is to give an end-user an opportunity to make a
- conscious decision to approve, and possibly modify, the information
- pertaining to the web application before installing it. This also
- gives the end-user an opportunity to discern if the web application
- is spoofing another web application, by, for example, using an
- unexpected icon or name.
+ It is RECOMMENDED that UI that affords the end user the ability to
+ install a web application also allow inspecting the icon,
+ name, start URL, origin, etc. pertaining to a web application.
+ This is to give an end-user an opportunity to make a conscious
+ decision to approve, and possibly modify, the information pertaining
+ to the web application before installing it. This also gives the
+ end-user an opportunity to discern if the web application is spoofing
+ another web application, by, for example, using an unexpected icon or
+ name.
It is RECOMMENDED that user agents prevent other applications from
@@ -583,204 +482,22 @@
- Installation events and supporting the {{BeforeInstallPrompt}} is
- OPTIONAL.
-
DOM events fired by this specification use the application
life-cycle task source.
- The BeforeInstallPromptEvent is dispatched when the site is
- allowed to present a site-triggered install prompt, or prior
- to the user agent presenting an automated install prompt. It
- allows the site to cancel the automated install prompt, as
- well as manually present the site-triggered install prompt.
-
- The PromptResponseObject contains the result of calling
- prompt(). It
- contains one member, userChoice, which states the user's
- chosen outcome.
-
- An instance of a BeforeInstallPromptEvent has the following
- internal slots:
-
- The prompt method, when called, runs the following
- steps:
-
- To request to present an install prompt
- with BeforeInstallPromptEvent event:
-
- This example shows how one might prevent an automated install
- prompt from showing until the user clicks a button to show a
- site-triggered install prompt. In this way, the site can
- leave installation at the user's discretion (rather than prompting
- at an arbitrary time), whilst still providing a prominent UI to do
- so.
-
- The AppBannerPromptOutcome enum's values represent the
- outcomes from presenting an install prompt.
-
- The following extensions to the
-
- Install prompts
-
-
-
-
-
-
-
-
-
-
-
- beforeinstallprompt
, with its
- cancelable
attribute initialized to true.
-
Privacy and security considerations
Installation Events
-
- BeforeInstallPromptEvent Interface
-
-
- [Exposed=Window]
- interface BeforeInstallPromptEvent : Event {
- constructor(DOMString type, optional EventInit eventInitDict = {});
- Promise<PromptResponseObject> prompt();
- };
-
- dictionary PromptResponseObject {
- AppBannerPromptOutcome userChoice;
- };
-
- enum AppBannerPromptOutcome {
- "accepted",
- "dismissed"
- };
-
-
-
- false
. Represents whether this
- event was used to present an install prompt to the end-user.
-
-
- prompt()
method
-
-
-
-
- isTrusted
attribute
- is false
, reject
- this.[[\userResponsePromise]] with
- {{"NotAllowedError"}}, optionally informing the developer that
- untrusted events can't call prompt()
.
- false
, set this.[[\didPrompt]]
- to true
, then in parallel, request to
- present an install prompt with this event. Wait, possibly
- indefinitely, for the end-user to make a choice.
-
-
-
- Usage example
-
-
- window.addEventListener("beforeinstallprompt", event => {
- // Suppress automatic prompting.
- event.preventDefault();
-
- // Show the (disabled-by-default) install button. This button
- // resolves the installButtonClicked promise when clicked.
- installButton.disabled = false;
-
- // Wait for the user to click the button.
- installButton.addEventListener("click", async e => {
- // The prompt() method can only be used once.
- installButton.disabled = true;
-
- // Show the prompt.
- const { userChoice } = await event.prompt();
- console.info(`user choice was: ${userChoice}`);
- });
- });
-
-
-
- AppBannerPromptOutcome
enum
-
-
-
- Extensions to the
Window
object
+ Extensions to the `Window` object
Window
object specify
- the event handler idl attribute on which events relating to
- the installation of a web application are fired.
+ The following extensions to the {{Window}} object specify the
+ event handler idl attribute on which events relating to the
+ installation of a web application are fired.
partial interface Window {
attribute EventHandler onappinstalled;
- attribute EventHandler onbeforeinstallprompt;
};
application).
onbeforeinstallprompt
attribute
- - The onbeforeinstallprompt is an event handler IDL - attribute for the "beforeinstallprompt" event type. - The interface used for these events is the - BeforeInstallPromptEvent interface (see the steps to - notify that an install prompt is available). -
-- The steps to install the web application are given by the - following algorithm: -
-appinstalled
- at the the {{Window}} object of the top-level browsing
- context for which the installation took place.
- - User agents SHOULD provide a mechanism for the user to remove the - installed application. + User agents SHOULD provide a mechanism for the user to remove an + installed web application.
It is RECOMMENDED that at the time of removal, the user agent also @@ -483,56 +455,6 @@
- DOM events fired by this specification use the application - life-cycle task source. -
-- The following extensions to the {{Window}} object specify the - event handler idl attribute on which events relating to the - installation of a web application are fired. -
-- partial interface Window { - attribute EventHandler onappinstalled; - }; --
- function handleInstalled(ev) { - const date = new Date(ev.timeStamp / 1000); - console.log(`Yay! Our app got installed at ${date.toTimeString()}.`); - } - - // Using the event handler IDL attribute - window.onappinstalled = handleInstalled; - - // Using .addEventListener() - window.addEventListener("appinstalled", handleInstalled); --
onappinstalled
attribute
-
- The onappinstalled is an event handler IDL
- attribute for the "appinstalled" event type. The
- interface used for these events is the Event
- interface [[DOM]]. This event is dispatched as a result of a
- successful installation (see the steps to install the web
- application).
-
+ Non-standard extensions to this specification are being "incubated" in + parallel by the Web Community. If two or more implementers decide to + support an incubated feature, then those features will become part of + this specification in the future: +
+link
and meta
elements
From 2b863c9ff0e3c2241379715d64baa7579feed276 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Marcos=20C=C3=A1ceres?= Event
- interface
- - Non-standard extensions to this specification are being "incubated" in - parallel by the Web Community. If two or more implementers decide to - support an incubated feature, then those features will become part of - this specification in the future: + Extensions to this specification are being incubated in parallel by the + Web Community, some of which are shipping in multiple browsers. If two + or more browser engines end up supporting an incubated feature, then + those features will become part of this specification in the future - + allowing them to become a standard the Web Platform:
It is RECOMMENDED that UI that affords the end user the ability to - install a web application also allow inspecting the icon, + install a web application also allows inspecting the icon, name, start URL, origin, etc. pertaining to a web application. This is to give an end-user an opportunity to make a conscious decision to approve, and possibly modify, the information pertaining @@ -3465,18 +3465,6 @@
Event
- interface
-