目录

Redirecting to an App in a Specified Way Using the Cross-Platform Link Capability

Use Cases

The cross-platform link capability is supported since API version 6.0.0(20).

It enables app redirection on HarmonyOS devices in a specified way. After tapping a cross-platform link, users will be redirected to a HarmonyOS preview page, an app details page on AppGallery, a custom URL, a deep link, or another designated page.

Cross-platform links are primarily used to send app promotional information directly to users, for example, sharing product campaigns or app promotional activities via SMS, email, or social media.

Prerequisites

You have enabled App Linking.

Development Process

Party Procedure
Cloud-side development Enable App Linking.
Cloud-side development Request a URL prefix in AppGallery Connect, add a trusted URL format, and create a cross-platform link.
App-side development Configure a cross-platform link in the module.json5 file.
App-side development Process the link passed by the caller app.
App-side development Verify the app launch effect.

[h2]Requesting a URL Prefix

A URL prefix is a part of a cross-platform link, which follows the format of https://domain name. Before creating a cross-platform link, you need to request a URL prefix.

  1. Sign in to AppGallery Connect and click Development and services.

  2. Click the project to which your HarmonyOS app belongs. (Ensure that all versions of the app across different platforms are contained within the same project.)

  3. In the navigation tree, choose Grow > App Linking > Cross-platform links. On the page displayed, click the URL prefixes tab, and click New URL prefix.

  4. Set a prefix for the free domain name provided by AppGallery Connect. The prefix must be unique and contain only lowercase letters and digits. Then click Next.

  5. View the complete domain name displayed after it is verified.

[h2]Adding a Trusted URL Format

Before creating a cross-platform link, you need to add a trusted URL format to define the format of deep links and custom URLs. Once configured, redirection is restricted to URLs that match the trusted format, helping prevent website spoofing.

  1. Sign in to AppGallery Connect and click Development and services.

  2. Click the project to which your HarmonyOS app belongs. (Ensure that all versions of the app across different platforms are contained within the same project.)

  3. In the navigation tree, choose Grow > App Linking > Cross-platform links. On the page displayed, click the URL trustlist tab, and click New trusted URL format.

  4. Add a trusted URL format using regular expressions, and then click Release in the upper right corner.

Verifying the App Launch Effect

[h2]Starting the App Through the System Browser or ArkWeb

ArkWeb deeply integrates App Linking. When a user taps a cross-platform link in the system browser or on an embedded web page in an app that integrates ArkWeb, the target app is preferentially started through App Linking if a matching app is available. However, there are certain restrictions: