Skip to content

Commit 0bc7f4d

Browse files
authored
updates the explainer to require an app id (#843)
* same-origin web install can install any content on the web but requires an id.
1 parent 44d1060 commit 0bc7f4d

File tree

1 file changed

+12
-14
lines changed

1 file changed

+12
-14
lines changed

WebInstall/explainer_same_domain.md

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,14 @@ The site can trigger its own installation.
3939

4040
The current way of supporting installation is vai the `onbeforeinstallprompt` event, which only works in browsers that have a prompting UI affordace.
4141

42-
The `navigator.install()` method allows a imperative way to install web content, and works for UAs that prompt and don't prompt:
42+
The `navigator.install` method allows a imperative way to install web content, and works for UAs that prompt and don't prompt:
4343

4444
```javascript
4545
/* tries to install the current domain */
4646
const installApp = async () => {
4747
if (!navigator.install) return; // api not supported
4848
try {
49-
await navigator.install();
49+
await navigator.install('content_id_123');
5050
} catch(err) {
5151
switch(err.name){
5252
case 'AbortError':
@@ -59,11 +59,11 @@ const installApp = async () => {
5959

6060
![Same domain install flow](./samedomaininstall.png)
6161

62-
The **`navigator.install()` method can overlap with some functionality of `beforeinstallprompt` for same-origin installation**. When the method is called it will trigger the UA to prompt for the installation of an application. This is analogous to when the end user clicks on an affordance that the UA might have to inform the user of installing. On Edge, Chrome (desktop) and Samsung Internet (mobile), this would be when the user clicks on the 'app available' banner or related UX that appears on the omnibox of the browser. For browsers that do not implement prompting, the expected behaviour is analogous to their installation paradigm. For example, in Safari (desktop) the behaviour might be that it shows a dialog to add the content to the dock as an app.
62+
The **`navigator.install` method can overlap with some functionality of `beforeinstallprompt` for same-origin installation**. When the method is called it will trigger the UA to prompt for the installation of an application. This is analogous to when the end user clicks on an affordance that the UA might have to inform the user of installing. On Edge, Chrome (desktop) and Samsung Internet (mobile), this would be when the user clicks on the 'app available' banner or related UX that appears on the omnibox of the browser. For browsers that do not implement prompting, the expected behaviour is analogous to their installation paradigm. For example, in Safari (desktop) the behaviour might be that it shows a dialog to add the content to the dock as an app.
6363

64-
On UAs that support prompting, the threshold for `navigator.install()` to resolve on same-origin installations uses the same checks that `onbeforeinstallprompt` currently has for prompting (if required by the UA). The promise doesn't resolve unless the *installability criteria* is met. *Note that the criteria defined by UAs varies and can be that there is NO criteria*.
64+
On UAs that support prompting, the threshold for `navigator.install` to resolve on same-origin installations uses the same checks that `onbeforeinstallprompt` currently has for prompting (if required by the UA). The promise doesn't resolve unless the *installability criteria* is met. *Note that the criteria defined by UAs varies and can be that there is NO criteria*.
6565

66-
When called on the same domain, the **`install()` method will trigger/open the prompt for installation the same way that using `onbeforeinstallprompt` does right now for browser that prompts.** If there is an error with the installation, then the promise returns a `DOMException` of type 'AbortError'.
66+
When called on the same domain, the **`install` method will trigger/open the prompt for installation the same way that using `onbeforeinstallprompt` does right now for browser that prompts.** If there is an error with the installation, then the promise returns a `DOMException` of type 'AbortError'.
6767

6868
*Any same-origin content can be installed even if it is **NOT** an application.*
6969

@@ -72,11 +72,11 @@ When called on the same domain, the **`install()` method will trigger/open the p
7272

7373
### The `navigator.install` method
7474

75-
To install a web site/app, the site/app would use the promise-based method`navigator.install(manifest_id[[, install_url], <params>])`. This method will:
75+
To install a web site/app, the site/app would use the promise-based method`navigator.install(<id>[[, install_url], <params>])`. This method will:
7676

7777
* Resolve when an installation was completed.
7878
* The success value will be an object that contains:
79-
* `manifest_id`: computed `manifest_id` of the installed application.
79+
* Computed `id`: computed `id` of the installed web content. This is the `id` that is passed on as a parameter to reference the installed content.
8080
* Be rejected if the prompt is not shown or if the app installation did not complete. It'll reject with a [`DOMException`](https://developer.mozilla.org/en-US/docs/Web/API/DOMException) value of:
8181
* `AbortError`: The installation was not completed.
8282

@@ -85,21 +85,19 @@ To install a web site/app, the site/app would use the promise-based method`navig
8585

8686
const installApp = async () => {
8787
try{
88-
const value = await navigator.install();
88+
const value = await navigator.install('content_id_123');
8989
}
9090
catch(err){console.error(err.message)}
9191
};
9292

9393
```
94-
9594
![Promises resolve/reject flow](./installPromises.png)
9695

9796
#### **Signatures of the `install` method (same-origin)**
9897
The same-origin part of the Web Install API consists of the extension to the navigator interface with the install method. The install method can be used in several different ways. There is no difference in behaviour when this is called from a standalone window or a tab.
9998

100-
1. `navigator.install([<params>])`: The method receives no parameters and tries to install the current origin as an app. Note that `manifest_id` *is required* for the installation and if the method is called without one it will use the *default* manifest id of the web content. The default manifest id resolves to the `start_url` if defined, or the document url if not defined.
101-
102-
2. `navigator.install(manifest_id[[, install_url], <params>])`: The method takes a manifest id and optional install url and tries to install the current origin as an app. If the content being installed has a manifest file, this must match the value in the manifest file. If there is no manifest file present, it must match the document url. The call can also receive an object with parameters that it can use to customize a same domain installation. These parameters alter how the app is installed and are defined in an object. More information about the parameters is found in the [Parameters](#parameters) subsection of this specification.
99+
1. `navigator.install(id[[, install_url], <params>])`: The method takes an id (and optional install url) and tries to install the current origin. If the content being installed has a manifest file, this `id` must match the value in the manifest file. If there is no manifest file present, this `id` will act as the app id for the installed content. This is relevant since if the installed content were to be given a manifest file and made into an application, there is a way to automatically update the app going forward.
100+
The call can also receive an object with parameters that it can use to customize a same domain installation. These parameters alter how the app is installed and are defined in an object. More information about the parameters is found in the [Parameters](#parameters) subsection of this specification.
103101

104102
#### **Parameters**
105103

@@ -119,7 +117,7 @@ To install a same domain web site/app, the process is as follows:
119117

120118
* **`navigator.install` and manifest file's `prefer_related_applications`:** When the `related_applications` and `prefer_related_applications` key/values are present in the manifest, the UA should try to handoff the install to the prefered catalog. If this is not possible then it fallback to a default UA install.
121119

122-
* **`navigator.install()` and getInstalledRelatedApps():** If a web app tries to install itself (same domain install) it can first use the `getInstalledRelatedApps()` to check if it is already installed and hide the installation UI.
120+
* **`navigator.install` and getInstalledRelatedApps():** If a web app tries to install itself (same domain install) it can first use the `getInstalledRelatedApps()` to check if it is already installed and hide the installation UI.
123121

124122
```javascript
125123

@@ -134,7 +132,7 @@ relatedApps.forEach((app) => {
134132
## Installability criteria
135133
In order for an application/site to be installed, it must comply with *installability criteria*. **This criteria is entirely up to the UA**, can *vary depending on the installation target*, and can be optional.
136134

137-
Modern browsers allow for different degrees of installation of different types of content, ranging from traditional web sites all the way up to Progressive Web Apps. **The core functionality of the same-origin version of the API is that it allows to install *anything* initiated with a user action**.
135+
Modern browsers allow for different degrees of installation of different types of content, ranging from traditional web sites all the way up to Progressive Web Apps. **The core functionality of the same-origin version of the API is that it allows to install *any content*, as long as it is initiated with a user action**. Note that even though there are no installability requirements, the `navigator.install` method does require an id to install *any content*.
138136

139137
A user agent might decide to have only the requirement of HTTPS to allow installation of a web site, or may need as well a manifest file and/or service worker to install a web app or might not require anything at all, allowing the user to install any content they wish.
140138

0 commit comments

Comments
 (0)