After the developers put their apps on the app market, they hope that there will be multiple portals to direct their apps, thus increasing the exposure rate of their apps and bringing more traffic. Deeplink capabilities, an open standard for fast apps, is what developers need.

Application scenarios

Deeplink can be used in the following scenarios:

  • Social sharing

Users can click on the Deeplink link to open the app directly by sharing it through social software.

  • Advertising promotion

Put the Deeplink link of kuaipai into the advertising promotion page, and users can click the link to directly open kuaipai.

  • Operating activities

If kuaiapp is used to attract users to participate in the operation activities, the Deeplink link of Kuaiapp can be embedded in the publicity page of the operation activities, so as to facilitate users’ participation.

Format support

Deeplink supports the following link formats:

It is recommended to use

hap://app/<package>/[path][?key=value]
https://hapjs.org/app/<package>/[path][?key=value]
Copy the code

Only applicable to Huawei phones:

hwfastapp://<package>/[path][?key=value]
Copy the code
  • Package: specifies the application package name. This parameter is mandatory.

  • Path: specifies the path of the application page. If this parameter is not specified, the home page is used by default.

  • Key-value: specifies the parameter to be sent to the page. Multiple parameters can be selected. Parameter values may be obtained by other applications. Therefore, do not transfer data with high security sensitivity.

The development process

This section uses Com.huawei. QuickApp as an example to explain Deeplink usage.

Json file, we can get the following information:

  • Package name: com.huawei.QuickApp.

  • Application name: Demo.

  • Page: contains Hello and Detail pages. Hello is the home page.

Example code for Deeplink to open quick App Demo is as follows:

import router from '@system.router'
router.push({
uri: 'hap: / / app/com. Huawei. Quickapp'})Copy the code

Click the link in the web page to open the quick application demo example code is as follows:

<html>
   <head>
       <meta charset="UTF-8">< title></title> </head> <body> <a href= "hap:/ / app/com. Huawei. Quickapp "> jump to quick application demo < / a >
   </body>
</html>
Copy the code

In the example above, there is no specific page to jump to, so the default page of the quick application Demo is Hello. If you want to adjust to the Detail page, the code can be changed to:

import router from '@system.router'
router.push({
uri: 'hap: / / app/com. Huawei. Quickapp/Detail'})Copy the code

If you also need to pass parameters to the Detail page, you can concatenate the parameters in key-value form, using & concatenation for multiple parameters. Assuming the source and name parameters are passed to the Detail page, the code is changed to:

import router from '@system.router'
router.push({
         uri: 'hap://app/com.huawei.quickapp/Detail? The source = net&name = aa '})Copy the code

The code for obtaining parameter values after logging into the Detail page is as follows:

onShow: function () {
         var nameValue=this.name;
         var sourceValue=this.source;
}
Copy the code

Once developed, Deeplink can be tested locally to verify the accuracy of jump links.

Note: Before the test, ensure that the huawei Quick Application loader has the usage record of the target quick application.

test

Method 1: Use the Android ADB command (the COMPUTER must be configured with adb environment)

adb shell am start -a android.intent.action.VIEW -d hap://app/com.huawei.quickapp/Detail

Note: Using command tests is not suitable for scenarios where multiple parameters are passed.

Method 2: Add the Deeplink hyperlink you want to test to a local web page

<! DOCTYPE html> <html> <head> <meta charset="UTF-8">
        <title></title>
    </head>
  
    <body>
         <script type="text/javascript">
             window.location.href="hap://app/com.huawei.quickapp/Detail? source=net&name=aa";
        </script>  
  </body>
</html>
Copy the code

For more details, please refer to:

Faster application development guide: developer.huawei.com/consumer/cn…

Deeplink access guidelines: developer.huawei.com/consumer/cn…

Participate in developer discussion please to Reddit community: www.reddit.com/r/HMSCore/

Download the demo and sample code at Github: github.com/HMS-Core

Solve the integration problem please to Stack Overflow:stackoverflow.com/questions/t…


The original link: developer.huawei.com/consumer/cn…

Author: Chao Youting, Drum Tower