URI Scheme best practices
resource
exist Web era, we recommend the use of Restful architecture because Restful be able to make better use of existing Web Some guidelines and constraints in the standard. Although Rest itself subject to Web The impact of technology is profound, but in theory Rest Architectural style is not bound to HTTP above, and Rest with resources and URI The relationship is very close. So what are resources? Anything that needs to be referenced is a resource. A resource can be an entity (such as a mobile phone number) or just an abstract concept (such as a value). Here are some examples of resources:
- A user’s mobile phone number
- A user’s personal information
- Most ordered by users GPRS combo
- Dependencies between two products
- Discount packages that a certain user can apply for
- The potential value of a mobile phone number
unique identifier
For a resource to be identifiable, it needs a unique identifier. Web The only identifier in this is URI(Uniform Resource Identifier)。URI It can be regarded as both the address of the resource and the name of the resource.
Likewise, in App Here we use URI Scheme Just like locating a web page, you can locate an application or even a specific function in the application.URI Scheme The general format is: scheme:[//[user:password@]host[:port]][/]path[?query][#fragment]
Generally, we recommend using URI Scheme: scheme://host/path?query
The example shown in the figure below shows uri and its various components.

Scheme
So URI Scheme How does it work? Take Dianping’s official website and Dianping App Let’s make a simple comparison to illustrate. The former is for web pages url, the latter is App of URI Scheme。
| Web page | app | |
|---|---|---|
| Home page/Open application | http://www.dianping.com/ | dianping:// |
| Subpages/specific functions | http://www.dianping.com/shop/1859284/ | dianping://shopinfo?id=1859284 |
here,http://www.dianping.com and dianping:// They all declared whose territory this was. then inhttp://www.dianping.com add after /shop/1859284/ Just jump to the subordinate http://www.dianping.com on a webpage of; similarly, on dianping:// add after shopinfo?id=1859284 Entered Dianping App A specific page - Raffles City Shanghai.
Therefore, every App If you plan your own URI Scheme, then it can be convenient for other App Quickly wake up one of its functions.
Taking Che Guevara as an example, his URI Scheme Just very well planned, fine-grained control.
- Movie Listserv: Access to Che Guevara App 's movie list page
- Movie Details Service: Access to Che Guevara App The details page of a certain movie. of this service URI Scheme Similar to gewara://com.gewara.movie?movieid=123456
- Cinema Details Service: Access to Che Guevara App A movie theater page. of this service URI Scheme Similar to gewara://com.gewara.movie?cinemaid=123456
- Cinema Showing Service: Ability to view Che Guevara based on date App The movie schedule of a certain theater in China. of this service URI Scheme Similar to gewara://com.gewara.movie?cinemaid=123456&date=2016-05-20
- Video Video Service: Access to Che Guevara App View trailers for a particular video. of this service URI Scheme Similar to gewara://com.gewara.movie?videoNo=789000&movieid=123456
These URI Scheme Guevara is more representative, with these Schemes Can facilitate other App Wake up Guevara quickly App, and it is also convenient to use the H5 page to awaken the native Guevara App. It not only facilitates traffic drainage, but also facilitates App of self-growth.
JMLinkApplications in
JMLink sdk is to do deep link Yes, it supports URI Scheme Dynamic value transfer, in [scheme://][host:port][path][?query][#fragment] format, only in path and query Mid pass value.
For example, a complete with dynamic parameters URL Scheme Configuration wqeq://www.mycompany.com/:userId?firstparamkey=:key1&secondparamkey=:key2, it is recommended toJMLinkThe complete structure of the background configuration (includingscheme/host:prot/path/query)of URL Scheme information
- "Colon:": inschemebetween head and command;
- "Double slash //": Between the link header and the command, ifhostIf omitted, it will be three slashes ///;
- "Question mark?": between the command and the parameter;
- "Equal sign =": between parameters and values;
- "Ampersand": Between one set of parameters and another set of parameters.
| part | parameter | significance |
|---|---|---|
| scheme | wqeq:// | a field of application |
| host:port | www.mycompany.com | a domain name |
| path | /:userId | Path placeholder, there can be multiple, each is connected with / likepath1/path2/path3 |
| query | ?firstparamkey=:key1&secondparamkey=:key2 | parameter:firstparamkey,secondparamkey value:key1,key2,inkey1andkey2 is a placeholder |
tips
URL Scheme 配置需和客户端协定,占位符通过 JS SDK 方法传递参数,完成赋值。如不使用占位符(动态参数),亦可在极光魔链的短链管理中给 URI 的参数赋值 wqeq://www.mycompany.com/shopping?firstparamkey=123456&secondparamkey=654321
path Examples of dynamic value transfer in
- myapp://myhost.com/:userId
- userId Representation is a dynamic parameter, and the service it represents can be a user-centered service.
query Examples of dynamic value transfer in
myapp://myhost.com?order=:orderId
orderId Represents a dynamic parameter, and the service it represents can be a service for querying an order
myapp://myhost.com?cityId=:cityId&hotelBrand=:hotelBrand
in cityId、hotelBrand Representation is a dynamic parameter, and the service it represents can be a list service of a certain hotel brand in a certain city.
path、query Examples of dynamic value transfer in
- myapp://myhost.com/:userId?order=:orderId
- userId and orderId Represents a dynamic parameter, and the service it represents can be a service for querying an order of a certain user.