[Huawei Developers] Martin Bieber:
Multiple entries to a quick app released on AppGallery help improve the quick app's impressions and bring more traffic to developers. Standard deep links are provided to implement this function.

Deep links can be applied in the following scenarios:

l Sharing on social platforms

The deep link of a quick app shared through social platforms can redirect a user to the quick app after the user taps the deep link.

l Advertising

The deep link of a quick app embedded in an ad can redirect a user to the quick app after the user taps the deep link.

l Operational events

The deep link of a quick app embedded in the promotion page of an operational event can make it easier for users to participate in the event.

The following formats are supported:

(Recommended) hap://app/<package>/[path][?key=value]

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

(Applicable to Huawei phones only) hwfastapp://<package>/[path][?key=value]

l package: App package name, which is mandatory.

l path: Path of the page in the app. This parameter is optional. If this parameter is not set, the home page is used by default.

l key-value: Parameter to be passed to the page. This parameter is optional. Multiple key-value pairs are allowed. The passed parameter values may be obtained by other apps. Therefore, you are advised not to transfer data with high security sensitivity.

The following takes a demo quick app with a package name of com.huawei.quickapp as an example to describe how to use deep links.

The following information is obtained from the manifest.json file of the demo quick app.

l package: com.huawei.quickapp

l name: demo

l pages: include the Hello page and the Detail page, with Hello being the home page.

The sample code for calling the deep link to open the demo quick app is as follows:

import router from '@system.router'

router.push({

uri: 'hap://app/com.huawei.quickapp'

})

The sample code for opening the demo quick app after a user taps a link on a web page is as follows:

<html>

<head>

<meta charset="UTF-8">

<title></title>

</head>

<body>

<a href="hap://app/com.huawei.quickapp" > redirect to a demo quick app</a>

</body>

</html>

In the preceding example, the page to which a user is redirected is not configured. Therefore, the Hello page of the demo quick app is displayed by default. To display the Detail page, modify the code as follows:

import router from '@system.router'

router.push({

uri: 'hap://app/com.huawei.quickapp/Detail'

})

If parameters need to be transferred to the Detail page, add the parameters to the code in the key-value format. Multiple parameters are separated by ampersands (&). If the source and name parameters are transferred to the Detail page, the code is modified as follows:

import router from '@system.router'

router.push({

uri: 'hap://app/com.huawei.quickapp/Detail?source=net&name=aa'

})

The code for obtaining the values of the parameters that have been transferred to the Detail page is as follows:

onShow: function () {

var nameValue=this.name;

var sourceValue=this.source;

}

You can test the redirection of the deep link after the development is complete.

Notice: Before the test, ensure that usage records of the quick app to be redirected to exist in Quick App Loader.

[Test Method 1] Run the android adb command. (The ADB environment must be configured on your computer.)

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

Notice: This method does not apply to scenarios where multiple parameters are transferred.

[Test Method 2] Add the deep link to be tested 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>