diff --git a/explainer.md b/explainer.md index 106b4c838..a6bd10e1e 100644 --- a/explainer.md +++ b/explainer.md @@ -250,6 +250,26 @@ Numerous operating systems grant native applications the ability to add menu ite ] ``` +## Adding protocol handlers +Native applications often register themselves as protocol handlers to increase discoverability and usage. For web applications, you can define a set of protocol handlers to be exposed when the app is installed. Each protocol handler item must have the protocol to be handled and the URL used to handle the protocol links. + +```JSON +"protocol_handlers": [ + { + "protocol": "mailto", + "url": "/mailto?%s", + }, + { + "protocol": "sms", + "url": "/sms?number=%s", + }, + { + "protocol": "web+msg", + "url": "/msg?handler=%s", + } +] +``` + ## How can I detect if the user "installed" my app? The spec provides a way for you to detect when the user installs your apps by registering for "appinstalled" events. diff --git a/index.html b/index.html index a9294c1a3..4e9e36924 100644 --- a/index.html +++ b/index.html @@ -1171,6 +1171,11 @@
shortcuts
member given
manifest["shortcuts"] and manifest URL.
+ protocol_handlers
+ member given manifest["protocol_handlers"] and
+ manifest URL.
+ @@ -2080,6 +2086,111 @@
protocol_handlers
member
+ + The protocol_handlers member is an array of + ProtocolHandlerItems that allows a web application to handle + URL protocols. +
++ Protocol handlers could, for instance, be used for web app + communication where one app directly invokes another and passes data + via custom protocol links. +
++ How protocol handlers are presented, and how many of them are shown + to the user, is at the discretion of the user agent and/or operating + system. +
+
+ The steps for processing the protocol_handlers
+ member are given by the following algorithm. The algorithm
+ takes a sequence<ProtocolHandlerItem>
+ protocol_handlers and a URL manifest
+ URL. This algorithm returns a sequence<ProtocolHandlerItem>.
+
+ A user agent SHOULD ask users for permission before registering a + ProtocolHandlerItem protocol_handler as the default + handler for a protocol with the host operating system. A user agent + MAY truncate the list of ProtocolHandlerItem + protocol_handler presented in order to remain consistent + with the conventions or limitations of the host operating system. +
++ In the following example, the developer has included two + ProtocolHandlerItem protocol_handler. Assuming + the the manifest's URL is + https://example.com/manifest.webmanifest: +
++ { + "protocol_handlers": [ + { + "protocol": "web+music", + "url": "/play?songId=%s" + }, + { + "protocol": "store", + "url": "/buy?songId=%s" + } + ] + } ++
+ dictionary ProtocolHandlerItem { + required DOMString protocol; + required USVString url; + }; ++
+ Each ProtocolHandlerItem represents a protocol that the web + application wants to handle and the corresponding URL that should + handle the request. A user agent SHOULD use these values to register + the web application as a handler with the operating system. When the + user activates a protocol handler URL, the user agent SHOULD run + Handling a protocol launch. +
+
+ [[HTML]]'s registerProtocolHandler
method allows web sites
+ to register themselves as possible handlers for particular protocols.
+ What constitutes valid protocol
and url
+ values for ProtocolHandlerItems is defined in that API. Also
+ note that the [[HTML]] API uses scheme
where we use
+ protocol
but the same restrictions apply.
+
protocol
member
+ + The protocol member of a ProtocolHandlerItem is a + string that represents the protocol to be handled, such as + "mailto" or "web+auth". +
+
+ The protocol member of a ProtocolHandlerItem is
+ equivalent to registerProtocolHandler
's
+ scheme
argument defined in [[HTML]], and is processed in
+ the same manner.
+
url
member
+ + The url member of a ProtocolHandlerItem is the + URL within the + application's scope that opens when the associated protocol is + activated. +
+
+ The url member of a ProtocolHandlerItem is equivalent
+ to registerProtocolHandler
's url
argument
+ defined in [[HTML]], and is processed in the same manner.
+
+ When a ProtocolHandlerItem protocol_handler having + WebAppManifest manifest is invoked, run the + following steps: +
+