url scheme

Recently, due to business reasons, the H5 side was asked to do some requirements, but due to time reasons, it was too late, so the temporary solution was to add an entry to evoke the client on the H5 page. So I studied this communication method should be to use URL Scheme, URL Scheme is a page jump protocol, through this protocol we can realize the mutual jump of each page inside the app,

The app can be evoked through the browser or H5 page, and can also evoke and communicate with each other between the two apps.

The experience of the predecessors has guided that the format of this protocol is similar to the general URL format, which can be:

1、Scheme://Host:port/path?key=value    

2. Scheme://domain name

But in the actual implementation process, I found that Scheme can be defined by itself, and the latter must be called the package name of the app to be successful. I wonder if there are other configurations?

Below is my configuration code pasted:

Add the following configuration in the manifest file of the app you want to be invoked

   
   
   
   
   
   
What needs to be reminded here is that it is best not to use uppercase letters in the scheme, otherwise it will cause an invalid situation to be evoked on the H5 page!
Call method:
1. Directly enter the address corresponding to the configuration scheme in the address bar of the browser, for example: sx://com.example.fragmentnest Click search, and a pop-up box will prompt whether to open the app
    However, not all browsers can implement it, and interested students can try it.
2. On the H5 page window.localtion.href = " sx:// com.example.fragmentnest ";
3. Call each other between apps
    Intent intent = new Intent(Intent.ACTION_VIEW,Uri.parse("sx://com.example.fragmentnest"));
    startActivity(intent);

Criticisms and corrections are welcome!

                                                                                            


Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326453651&siteId=291194637