[Huawei Developers] Mayism:
With the unveiling of so many new functions and pages on HUAWEI AppGallery, it’s required a wide range of new redirection solutions on the platform.

However, the types of links, functions, apps, and scenarios that they are used, can vary great. It can be quite confusing sorting this all out, so I’ve outlined some common redirection scenarios for your reference.

Feel free to correct me, if you think that I’ve got something wrong, or am missing something.

1. Redirecting to the AppGallery Home Page

Usage case: You want to redirect the user from an app to the AppGallery home page, so that the user can search for related apps or activities quickly.

Method: Use the action method from Intent to implement the function.

action: com.huawei.appmarket.intent.action.MainActivity

Example:

public void launchAGHomePage() {
Intent intent = new Intent("com.huawei.appmarket.intent.action.MainActivity");
startActivity(intent);
}

2. Redirecting to an App’s Details Page on AppGallery

2.1 Intent-based Redirection from an In-App Page

Usage case: You want to redirect the user from an in-app page to the app’s details page, so the user can rate or comment on the app.

Methods: Use the action method from Intent to implement the function.

1. Method 1: by app ID

action:com.huawei.appmarket.appmarket.intent.action.AppDetail. withid

setPackage("com.huawei.appmarket");

name: "appId", value: "C100170981"

2. Method 2: by package name

action: com.huawei.appmarket.intent.action.AppDetail

setPackage("com.huawei.appmarket");

name: "APP_PACKAGENAME", value: "com.huawei.browser"

Note: Compared with method 2, method 1 includes additional appmarket and withid parameters from the action method.

Parameters involved:

Examples:

Method 1：by app ID

public void launchAppDetilPage1() {
Intent intent = new Intent("com.huawei.appmarket.appmarket.intent.action.AppDetail.withid");
intent.setPackage("com.huawei.appmarket");
intent.putExtra("appId", "C100170981");
startActivity(intent);
}

Method 2：by package name

public void launchAppDetilPage2() {
Intent intent = new Intent("com.huawei.appmarket.intent.action.AppDetail");
intent.setPackage("com.huawei.appmarket");
intent.putExtra("APP_PACKAGENAME", "com.huawei.browser");
startActivity(intent);
}

2.2 URL-based Redirection

Usage case: You want to redirect a user who clicks on a shared URL to an app’s details page.

Method: Create a URL with the following format:

hiapplink://com.huawei.appmarket?appId=yourAppID&channelId=yourChannelId&referrer=yourReferrer

Note: You’ll need to change the strings in either italic or bold only.

Parameters involved:

Example:

By app id

public void launchAppDetilWithURL1() {
String text1 = "hiapplink://com.huawei.appmarket?appId=C100170981&channelId=HwBrowserSearch&referrer=Keywords";
Uri uri = Uri.parse(text1);
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
startActivity(intent);
}

3. Launching All App Stores Installed on a Device to Redirect Users to an App’s Details Page in an App Store via MARKET

Usage case: You want to launch all app stores installed on the user’s device by passing a package name or app ID, so that the user can choose to go to the app’s details page in a desired app store.

Methods: Pass the link whose scheme is market://. Android supports the standard MARKET protocol, to ensure that all app stores can be launched on Android devices. The methods are as follows:

Method 1: market://details?id=pkgName // for all stores

Method 2: appmarket://details?id=pkgName // only for AppGallery

Method 3: market://com.huawei.appmarket.applink?appId=App ID" // only for AppGallery

Note: Method 1 is a standard method for Android devices, and is applicable to all app stores, such as Google Play and Tecent Appstore.

Parameters involved:

Examples:

// Method 1

public void launchAppDetilOnMarket1() {
String text1 = "market://details?id=com.huawei.browser";
Uri uri = Uri.parse(text1);
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
startActivity(intent);
}

// Method 2

public void launchAppDetilOnMarket2() {
String text1 = "appmarket://details?id=com.huawei.browser";
Uri uri = Uri.parse(text1);
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
startActivity(intent);
}

// Method 3

public void launchAppDetilOnMarket3() {
String text1 = "market://com.huawei.appmarket.applink?appId=C100170981";
Uri uri = Uri.parse(text1);
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
startActivity(intent);
}

4. Redirecting from a Web Link to an App’s Detail Page on the Web Version of AppGallery

Usage case: You want to redirect the user to an app’s details page on the web version of AppGallery, when the user clicks on a web link from the app’s official website, or a promotional web page.

Methods:

Method 1:https://appgallery.huawei.com/#/app/YOUR_APPID

Method 2:：https://appgallery.cloud.huawei.com/appDetail?pkgName=pkgName

Method 3:https://appgallery.huawei.com/#/app/YOUR_APPID?pkgName=pkgName

Method 4:https://appgallery.cloud.huawei.com/marketshare/app/ YOUR_APPID?locale=LOCALE&shareTo=WAP&shareFrom=channeID

Parameters involved:

Examples:

// Method 1: by app ID

https://appgallery.huawei.com/#/app/C100170981

// Method 2: by package name

https://appgallery.cloud.huawei.com/appDetail?pkgName=com.huawei.browser

// Method 3: by app ID and package name

https://appgallery.huawei.com/#/app/C100170981?pkgName=com.huawei.browser

// Method 4: by complete link with optional parameters (not commonly used, and generally used for badge-based promotions).

HUAWEI Browser

Huawei AppGallery

appgallery.cloud.huawei.com

5. Redirecting from a Badge Link to the App Detail Page on AppGallery

When a badge link of AppGallery appears as an image of AppGallery, by clicking this link, the user will be redirected to an app’s details page on AppGallery. If you hope to market your app, you can use this badge directly. In essence, it still functions as a link, no different than any other web link.

Use cases: If you have developed and released an app, and want to divert traffic from your website or another source to AppGallery, a badge can be ideal.

How to make a badge: The method for creating a badge is rather simple. You only need to sign in to AppGallery Connect, and click AppGallery Download. Then you proceed to make the badge as prompted.

Restrictions: You can only make a badge for apps that have been released, with a maximum of one badge for each app. Once a badge has been created, you can query for it on the Search badge tab page.

Badge use instructions:

You can find a created badge on the Search badge tab page, and download the badge or copy its link. I’ll walk you through some common operations:

Badge download: You will obtain a PNG image, which can be displayed on your website, or on a marketing HTML5 page.

Link creation: You can create a link for a specific channel, for example, Facebook or Baidu.

Link copying: You can download a link for a specific channel.

Usage example:

// 1. Typical link

https://appgallery.huawei.com/#/app...EDCCBCD90A86F29A8DA2400AA4163&detailType=0&v=

// 2. Typical badge with a link, which can be clicked

6. App Linking, with Cross-Platform Link Support

App Linking is a new service provided by AppGallery Connect. Since it’s new, I’ll give you a brief overview of what it is.

The service provides links that can work on a diverse range of platforms, such as Android, iOS, and PC browsers, making it similar in this way to Dynamic Links of Firebase, enabling you to quickly build cross-platform links, which can be easily shared.

In what scenarios can I use App Linking? I’ll give you an example to help illustrate how the service can be used. It’s an app that’s available on both Android and iOS devices, and thus requires a promotional activity that reaches users on both platforms. To engage users, we’ll need to send them an activity invitation link that works on Android and iOS alike. Also, some users may be opening the link in a PC browser, and in this case, that link should also support an HTML5 page for the activity.

What benefits does App Linking offer? Here, two scenarios should be considered:

The user’s device has already installed the app: App Linking will automatically open the app, and show the user the target page.

The user’s device has not installed the app: The link will prompt the user to open the app’s details page on AppGallery, or any other app store (configurable), and download the app. Then, when the user opens the downloaded app, the target page will appear.

How does App Linking work? Links of App Linking can be created in any of the following ways:

Creation on the console: All operations are performed in AppGallery Connect. You’ll need to click My projects, click your project, and go to Grow > App Linking. To create a link of App Linking, create a URL prefix first.This mode is recommended if you’re not familiar with coding. A step will require you to provide a deep link, which will need to be obtained from your R&D personnel.

Creation in your iOS app: This mode is similar to the previous one.

The only difference is that these links are for iOS users.

What if the user’s device is not a Huawei device?

Since App Linking supports both Android and iOS, many of you may be wondering how this service works on non-Huawei Android devices.

1. Can App Linking work for non-Huawei devices? You can be rest assured App Linking is not dependent on HMS Core, and thus is supported on all Android devices, regardless of whether they are running GMS or HMS.

2. What if the user has not installed the app and AppGallery? For Android devices that don’t have AppGallery installed, you can choose to open the link in the local app store that is installed. As long as your package name on that app store is the same as that on AppGallery, the user will be able to open your app’s details page on that app store.

Usage example:

// 1. Typical URL prefix

https://photoplaza.drcn.agconnect.link // In the prefix, photoplaza is unique to the app, and drcn.agconnect.link is a fixed.

// 2. Typical link of App Linking

https://photoplaza.drcn.agconnect.link/vm3Y

// 3. Code for creating a typical link of App Linking for Android

private static final String DOMAIN_URI_PREFIX = "https://photoplaza.drcn.agconnect.link";private static final String DEEP_LINK = "https://developer.huawei.com";public void createAppLinking() {
AppLinking.Builder builder = new AppLinking.Builder()
.setUriPrefix(DOMAIN_URI_PREFIX)
.setDeepLink(Uri.parse(DEEP_LINK))
.setAndroidLinkInfo(new AppLinking.AndroidLinkInfo.Builder().build());
String LongAppLinking = builder.buildAppLinking().getUri().toString();
}

// 4. Typical link of App Linking for iOS

- (IBAction)CreatLink:(id)sender {
AGCAppLinkingComponents *component = [[AGCAppLinkingComponents alloc] init];
component.uriPrefix = @"https://photoplaza.drcn.agconnect.link";
component.deepLink = @"https://www.developer.huawei.com";
component.iosBundleId = @"com.lucky.agc.demo";
component.iosDeepLink = @"agckit://ios/detail"; self.longlink.text = component.buildLongLink.absoluteString;
}

7. For Reference

Badge link document: https://developer.huawei.com/consum...ct-Guides/appgallery-agd-introduction-stamped

App Linking document: https://developer.huawei.com/consum.../agc-applinking-introduction-0000001054143215

Guide for adding a referrer: https://developer.huawei.com/consum...connect-Guides/appgallery-referrer-createlink

Guide for querying attribution information: https://developer.huawei.com/consum...ry-connect-Guides/appgallery-referrer-develop