npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@cordova-plugin-agconnect/applinking

v1.2.0

Published

Cordova Plugin AGC AppLinking

Downloads

1

Readme

Cordova Plugin AGC AppLinking


Contents


1. Introduction

This plugin enables communication between AGC AppLinking SDK and Cordova platform. It exposes all functionality provided by AGC AppLinking SDK.


2. Installation Guide

Before you get started, you must register as a HUAWEI Developer and complete identity verification on the HUAWEI Developer website. For details, please refer to Register a HUAWEI ID.

2.1. Creating a Project in AppGallery Connect

Creating an app in AppGallery Connect is required in order to communicate with the Huawei services. To create an app, perform the following steps:

  1. Sign in to AppGallery Connect and select My projects.
  2. Select your project from the project list or create a new one by clicking the Add Project button.
  3. Go to Project settings > General information, and click Add app.
    • If an app exists in the project and you need to add a new one, expand the app selection area on the top of the page and click Add app.
  4. On the Add app page, select platform Android or iOS and then enter the app information, and click OK.
  5. To use AGC App Linking, you need to enable the App Linking service first and also create App Linking URL Prefix. For more information, please refer to Enabling the App Linking Service.

2.2. Obtaining agconnect-services.json and agconnect-services.plist

  1. Sign in to AppGallery Connect and select your project from My Projects. Then go to Project settings > General information. In the App information field,
  • If platform is Android, click agconnect-services.json button to download the configuration file.
  • If platform is iOS, click agconnect-services.plist button to download the configuration file.

2.3. Cordova

  1. Install Cordova CLI.

    npm install -g cordova
  2. Create a new Cordova project or use existing Cordova project.

    • To create new Cordova project, you can use cordova create path [id [name [config]]] [options] command. For more details please follow CLI Reference - Apache Cordova.
  3. Update the widget id property which is specified in the config.xml file. It must be same with client > package_name value of the agconnect-services.json and agconnect-services.plist files.

  4. Add the Android or iOS platform to the project if haven't done before.

    cordova platform add android
    cordova platform add ios
  5. Install AGC AppLinking plugin to the project.

  • Run the following command in the root directory of your project to install it through npm.
cordova plugin add @cordova-plugin-agconnect/applinking

2.3.1. iOS App Development

  1. Copy agconnect-services.plist file to the app's root directory of your Xcode project.

  2. In an iOS app, when a user taps a link of App Linking, the link can be redirected in universal link or custom scheme mode.

  • Configuring a Universal Link: A user can be seamlessly redirected to the in-app content after tapping a universal link in iOS 9 and later versions. You only need to complete the following simple configuration to implement link redirection in iOS apps in universal link mode

    1. Generate an asset verification file of the domain. Sign in to AppGallery Connect, select your app, go to Project settings > General information > App information, and Team ID to set a team ID in the App Store. After the configuration is complete, AppGallery Connect will generate an asset verification file for the default domain.
    • After the asset verification file is generated, you can view it at https://your_applinking_url_prefix/apple-app-site-association. your_applinking_url_prefix is the domain name you applied for in AppGallery Connect.
    1. Declare the domain name associated with your iOS app. On the Signing & Capabilities tab page of your Xcode project, enable the Associated Domains function, and add a domain name to be supported, in applinks:your_applinking_url_prefix format. your_applinking_url_prefix is the domain name you applied for in AppGallery Connect.
  • Configuring a Custom Scheme: If you want a link to be opened in custom scheme mode in your iOS app, you need to set a custom scheme in the iOS deep link and set URL Schemes under URL Types on the Info tab page of your Xcode project.

  1. Run the application.

    cordova run ios --device

2.3.2. Android App Development

  1. Copy agconnect-services.json file to <project_root>/platforms/android/app directory your Android project.

  2. To use deep links to receive data, you need to add the following configuration to the activity for processing links. Set android:host to the domain name in the deepLink and android:scheme to the custom scheme. When a user taps a link containing this deep link, your app uses this activity to process the link.

    <!-- AndroidManifest.xml. /manifest/application/activity-->
    <intent-filter>
        <action android:name="android.intent.action.VIEW" />
        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />
        <!-- Add the custom domain name and scheme -->
        <data android:host="<DeepLink_Host>" android:scheme="https" />
    </intent-filter>
  3. Set Android launch mode in your Cordova project config.xml

     <preference name="AndroidLaunchMode" value="standard" />
  4. Run the application.

    cordova run android --device

2.4. Ionic

  1. Install Ionic CLI.

    npm install -g @ionic/cli
  2. Create a new Ionic project or use existing Ionic project.

2.4.1. With Cordova Runtime

  1. Enable the Cordova integration if haven't done before.

    ionic integrations enable cordova
  2. Update the widget id property which is specified in the config.xml file. It must be same with client > package_name value of the agconnect-services.json and agconnect-services.plist files.

  3. Set Android launch mode in your Ionic project config.xml

     <preference name="AndroidLaunchMode" value="standard" />
  4. Set preference in your Ionic project config.xml platform iOS.

     <preference name="deployment-target" value="11.0" />
     <preference name="SwiftVersion" value="5" />
  5. Add the Android or iOS platform to the project if haven't done before.

    ionic cordova platform add android
    ionic cordova platform add ios
  6. Install AGC AppLinking plugin to the project.

  • Run the following command in the root directory of your project to install it through npm.
ionic cordova plugin add @cordova-plugin-agconnect/applinking
  1. Copy agc-applinking folder from node_modules/@cordova-plugin-agconnect/applinking/ionic/dist/agc-applinking directory to node_modules/@ionic-native directory.
2.4.1.1. iOS App Development
  1. Copy agconnect-services.plist file to the app's root directory of your Xcode project.

  2. In an iOS app, when a user taps a link of App Linking, the link can be redirected in universal link or custom scheme mode.

  • Configuring a Universal Link: A user can be seamlessly redirected to the in-app content after tapping a universal link in iOS 9 and later versions. You only need to complete the following simple configuration to implement link redirection in iOS apps in universal link mode

    1. Generate an asset verification file of the domain. Sign in to AppGallery Connect, select your app, go to Project settings > General information > App information, and Team ID to set a team ID in the App Store. After the configuration is complete, AppGallery Connect will generate an asset verification file for the default domain.
    • After the asset verification file is generated, you can view it at https://your_applinking_url_prefix/apple-app-site-association. your_applinking_url_prefix is the domain name you applied for in AppGallery Connect.
    1. Declare the domain name associated with your iOS app. On the Signing & Capabilities tab page of your Xcode project, enable the Associated Domains function, and add a domain name to be supported, in applinks:your_applinking_url_prefix format. your_applinking_url_prefix is the domain name you applied for in AppGallery Connect.
  • Configuring a Custom Scheme: If you want a link to be opened in custom scheme mode in your iOS app, you need to set a custom scheme in the iOS deep link and set URL Schemes under URL Types on the Info tab page.

  1. Run the application.

    ionic cordova run ios --device
2.4.1.2. Android App Development
  1. Copy agconnect-services.json file to <project_root>/platforms/android/app directory your Android project.

  2. To use deep links to receive data, you need to add the following configuration to the activity for processing links. Set android:host to the domain name in the deepLink and android:scheme to the custom scheme. When a user taps a link containing this deep link, your app uses this activity to process the link.

    <!-- AndroidManifest.xml. /manifest/application/activity-->
    <intent-filter>
        <action android:name="android.intent.action.VIEW" />
        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />
        <!-- Add the custom domain name and scheme -->
        <data android:host="<DeepLink_Host>" android:scheme="https" />
    </intent-filter>
  3. Set Android launch mode in your Ionic project config.xml

     <preference name="AndroidLaunchMode" value="standard" />
  4. Run the application.

    ionic cordova run android --device

3. API Reference

Public Method Summary

| Return Type | Method Name | Defination | | ----------------------------------------------------------- | --------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | Promise<ShortLink> | buildShortLink(args: AppLinkingWithInfo) | This method is called to obtain a short link of App Linking with info in asynchronous mode. | | Promise<LongLink> | buildLongLink(args: AppLinkingWithInfo) | This method is called to obtain a long link of App Linking with info in asynchronous mode. | | Promise<void> | addListener(event, callback) | This method is called to obtain the ResolvedLinkDataResult from the asynchronous execution result, and parse the data, for example, deep links, passed through links of App Linking. |

Public Methods

buildShortLink

Generates a short link and a test URL.

| Parameters | Type | Definition | | ------------------ | ----------------------------------------- | ---------------------------------------------------------- | | appLinkingWithInfo | AppLinkingWithInfo | Sets information to be contained in a link of App Linking. |

| Return | Definition | | --------------------------------- | ------------------------------------------- | | Promise<ShortLink> | Short app link and test URL of App Linking. |

Call Example
Cordova
document.getElementById("buildShortLink").onclick = () => {
  const socialCardInfo1 = {
    description: "description short link",
    imageUrl:
      "https://developer.huawei.com/Enexport/system/modules/org.opencms.portal.template.core/resources/images/codelabs/ic_computergraphics.png",
    title: "title of social card",
  };
  const campaignInfo1 = {
    medium: "September",
    name: "ABC campaign",
    source: "Huawei",
  };
  const androidLinkInfo1 = {
    androidDeepLink: "https://developer.huawei.com/consumer/en/develop/",
    androidPackageName: "com.demo.ios.agc.applinking",
    androidOpenType:
      AGCAppLinking.AppLinkingAndroidLinkInfoAndroidOpenTypeConstants
        .LOCAL_MARKET,
  };
  const iosLinkInfo1 = {
    iosDeepLink: "cdvhuaweicom://consumer/en/develop/iosdeeplink",
    iosFallbackUrl: "https://swift.org/",
    iosBundleId: "com.demo.ios.agc.applinking",
  };
  const iTunesConnectCampaingnInfo1 = {
    iTunesConnectProviderToken: "iTunesConnectProviderToken1",
    iTunesConnectCampaignToken: "iTunesConnectCampaignToken1",
    iTunesConnectAffiliateToken: "iTunesConnectAffiliateToken1",
    iTunesConnectMediaType: "iTunesConnectMediaType1",
  };
  const appLinkingWithInfo = {
    socialCardInfo: socialCardInfo1,
    campaignInfo: campaignInfo1,
    androidLinkInfo: androidLinkInfo1,
    iosLinkInfo: iosLinkInfo1,
    iTunesConnectCampaingnInfo: iTunesConnectCampaingnInfo1,
    previewType:
      AGCAppLinking.AppLinkingLinkingPreviewTypeConstants.SOCIAL_INFO,
    uriPrefix: "https://uriprefixagcapplinking.dre.agconnect.link",
    deepLink: "huaweicom://consumer/en/develop/",
    shortAppLinkingLength: AGCAppLinking.ShortAppLinkingLengthConstants.LONG,
    expireMinute: 1000,
  };
  AGCAppLinking.buildShortLink(appLinkingWithInfo)
    .then((shortLinkResult) => {
      this.shortLinkResult = shortLinkResult;
      document.getElementById("shortLinkResult").innerHTML = JSON.stringify(
        shortLinkResult,
        null,
        1
      );
    })
    .catch((err) => {
      alert("buildShortLink -> Error : " + JSON.stringify(err, null, 1));
    });
};
Ionic
  buildShortLink() {
    const socialCardInfo1 = {
      description: 'description short link',
      imageUrl:
        'https://developer.huawei.com/Enexport/system/modules/org.opencms.portal.template.core/resources/images/codelabs/ic_computergraphics.png',
      title: 'title of social card',
    };
    const campaignInfo1 = {
      medium: 'july',
      name: 'summer campaign',
      source: 'Huawei'
    };
    const androidLinkInfo1 = {
      androidFallbackUrl: 'https://consumer.huawei.com/en/',
      androidOpenType: AppLinkingAndroidLinkInfoAndroidOpenTypeConstants.CUSTOM_URL,
      androidDeepLink: 'https://developer.huawei.com/consumer/en/programs/details',
      androidPackageName: 'com.demo.android.agc.applinking'
    };
    const iosLinkInfo1 = {
      iosDeepLink: "huaweicom://consumer/en/develop/iosdeeplink/details",
      iosFallbackUrl: "https://swift.org/",
      iosBundleId: "com.demo.ios.agc.applinking"
    };
    const iTunesConnectCampaingnInfo1 = {
      iTunesConnectProviderToken: "iTunesConnectProviderToken1",
      iTunesConnectCampaignToken: "iTunesConnectCampaignToken1",
      iTunesConnectAffiliateToken: "iTunesConnectAffiliateToken1",
      iTunesConnectMediaType: "iTunesConnectMediaType1"
    };
    const appLinkingWithInfo = {
      socialCardInfo: socialCardInfo1,
      campaignInfo: campaignInfo1,
      androidLinkInfo: androidLinkInfo1,
      iosLinkInfo: iosLinkInfo1,
      iTunesConnectCampaingnInfo: iTunesConnectCampaingnInfo1,
      uriPrefix: 'https://uriprefixagcapplinking.dre.agconnect.link',
      deepLink: 'https://developer.huawei.com/consumer/en/community/codelabs/details',
      expireMinute: 1050,
      shortAppLinkingLength: ShortAppLinkingLengthConstants.LONG,
      previewType: AppLinkingLinkingPreviewTypeConstants.SOCIAL_INFO
    };
    AGCAppLinking.buildShortLink(
      appLinkingWithInfo
    ).then((buildShortLinkResult) => {
      alert(JSON.stringify(buildShortLinkResult, null, 1));
    }).catch ((err) => {
      alert("Error buildShortLink: " + JSON.stringify(err, null, 1));
    });
}

buildLongLink

Generates a long link.

| Parameters | Type | Definition | | ------------------ | ----------------------------------------- | ---------------------------------------------------------- | | appLinkingWithInfo | AppLinkingWithInfo | Sets information to be contained in a link of App Linking. |

| Return | Definition | | ------------------------------- | ----------------------------- | | Promise<LongLink> | Long app link of App Linking. |

Call Example
Cordova
document.getElementById("buildLongLink").onclick = async () => {
  const socialCardInfo1 = {
    description: "description of long link",
    imageUrl:
      "https://developer.huawei.com/Enexport/system/modules/org.opencms.portal.template.core/resources/images/codelabs/ic_computergraphics.png",
    title: "title of social card",
  };
  const campaignInfo1 = {
    medium: "JULY",
    name: "summer campaign",
    source: "Huawei",
  };
  const androidLinkInfo1 = {
    androidDeepLink: "https://developer.huawei.com/consumer/en/develop/",
    androidFallbackUrl: "https://consumer.huawei.com/en/",
    androidPackageName: "com.demo.android.agc.applinking",
    androidOpenType:
      AGCAppLinking.AppLinkingAndroidLinkInfoAndroidOpenTypeConstants
        .CUSTOM_URL,
  };
  const iosLinkInfo1 = {
    iosDeepLink: "huaweicom://consumer/en/develop/iosdeeplink",
    iosFallbackUrl: "https://swift.org/",
    iosBundleId: "com.demo.ios.agc.applinking",
    //ipadFallbackUrl: '',
    //ipadBundleId: '',
  };
  const iTunesConnectCampaingnInfo1 = {
    iTunesConnectProviderToken: "iTunesConnectProviderToken1",
    iTunesConnectCampaignToken: "iTunesConnectCampaignToken1",
    iTunesConnectAffiliateToken: "iTunesConnectAffiliateToken1",
    iTunesConnectMediaType: "iTunesConnectMediaType1",
  };
  const appLinkingWithInfo = {
    socialCardInfo: socialCardInfo1,
    campaignInfo: campaignInfo1,
    androidLinkInfo: androidLinkInfo1,
    iosLinkInfo: iosLinkInfo1,
    iTunesConnectCampaingnInfo: iTunesConnectCampaingnInfo1,
    previewType:
      AGCAppLinking.AppLinkingLinkingPreviewTypeConstants.SOCIAL_INFO,
    uriPrefix: "https://uriprefixagcapplinking.dre.agconnect.link",
    deepLink: "https://developer.huawei.com/consumer/en/develop/",
    expireMinute: 1000,
  };
  AGCAppLinking.buildLongLink(appLinkingWithInfo)
    .then((longLinkResult) => {
      this.longLinkResult = longLinkResult;
      document.getElementById(("longLinkResult").innerHTML = JSON.stringify(longLinkResult, null, 1);
    })
    .catch((err) => {
      alert("Error buildLongLink: " + JSON.stringify(err, null, 1));
    });
};
Ionic
  buildLongLink() {
    const socialCardInfo1 = {
      description: 'description long link',
      imageUrl:
        'https://developer.huawei.com/Enexport/system/modules/org.opencms.portal.template.core/resources/images/codelabs/ic_computergraphics.png',
      title: 'title of social card',
    };
    const campaignInfo1 = {
      medium: 'july',
      name: 'summer campaign',
      source: 'Huawei'
    };
    const androidLinkInfo1 = {
      androidFallbackUrl: 'https://consumer.huawei.com/en/',
      androidOpenType: AppLinkingAndroidLinkInfoAndroidOpenTypeConstants.CUSTOM_URL,
      androidDeepLink: 'https://developer.huawei.com/consumer/en/programs/details',
      androidPackageName: 'com.demo.android.agc.applinking'
    };
    const iosLinkInfo1 = {
      iosDeepLink: "huaweicom://consumer/en/develop/iosdeeplink/details",
      iosFallbackUrl: "https://swift.org/",
      iosBundleId: "com.demo.ios.agc.applinking"
    };
    const iTunesConnectCampaingnInfo1 = {
      iTunesConnectProviderToken: "iTunesConnectProviderToken1",
      iTunesConnectCampaignToken: "iTunesConnectCampaignToken1",
      iTunesConnectAffiliateToken: "iTunesConnectAffiliateToken1",
      iTunesConnectMediaType: "iTunesConnectMediaType1"
    };
    const appLinkingWithInfo = {
      socialCardInfo: socialCardInfo1,
      campaignInfo: campaignInfo1,
      androidLinkInfo: androidLinkInfo1,
      iosLinkInfo: iosLinkInfo1,
      iTunesConnectCampaingnInfo: iTunesConnectCampaingnInfo1,
      uriPrefix: 'https://uriprefixagcapplinking.dre.agconnect.link',
      deepLink: 'https://developer.huawei.com/consumer/en/community/codelabs/details',
      expireMinute: 1050,
      shortAppLinkingLength: ShortAppLinkingLengthConstants.LONG,
      previewType: AppLinkingLinkingPreviewTypeConstants.SOCIAL_INFO
    };
    AGCAppLinking.buildLongLink(
        appLinkingWithInfo
      ).then((buildShortLinkResult) => {
      aler('shortLinkResult' + JSON.stringify(buildShortLinkResult, null, 1));
    }).catch ((err) => {
      alert("Error buildLongLink: " + JSON.stringify(err, null, 1));
    })
  }

addListener

Adds a listener for given event value.

| Parameters | Type | Definition | | ---------- | ---------------- | ----------------------------------------------------------- | | event | Events | Which event listener will be added for. | | callback | ResolvedLinkData | Callback function called when the given event is triggered. |

| Return | Definition | | -------------- | -------------- | | Promise<void> | Empty Promise. |

Call Example
Cordova
AGCAppLinking.addListener(
  AGCAppLinking.Events.RECEIVE_LINK,
  (resolvedLinkDataResult) => {
    alert(JSON.stringify(resolvedLinkDataResult, null, 1));
  }
);
Ionic
AGCAppLinking.addListener(Events.RECEIVE_LINK, (resolvedLinkDataResult) => {
  alert(JSON.stringify(resolvedLinkDataResult, null, 1));
});

Data Types

ResolvedLinkDataResult
  • Represents the data class of App Linking.

| Field | Type | Description | | ------------------ | ------ | ------------------------------------------------------------- | | deepLink | string | Obtains the deep link contained in a link of App Linking. | | clickTimeStamp | number | Obtains the time when a link of App Linking is tapped. | | socialTitle? | string | Address of the preview title displayed during social sharing. | | socialDescription? | string | Preview description displayed during social sharing. | | socialImageUrl? | string | Address of the preview image displayed during social sharing. | | campaignName? | string | Activity name. | | campaignMedium? | string | Activity medium. | | campaignSource? | string | Activity source. |

ShortLink
  • Represents the data structure of App Linking short link and test URL.

| Field | Type | Description | | --------- | ------ | ---------------------------------------------------------- | | shortLink | string | Short app link. | | testUrl | string | URL for previewing the flowchart of a link of App Linking. |

LongLink
  • Represents the data structure of App Linking long link.

| Field | Type | Description | | -------- | ------ | -------------- | | longLink | string | Long app link. |

SocialCardInfo
  • Represents the data structure of social sharing identifier information in App Linking.

| Field | Type | Description | | ------------ | ------ | ------------------------------------------------------------- | | description? | string | Preview description displayed during social sharing. | | imageUrl? | string | Address of the preview image displayed during social sharing. | | title? | string | Address of the preview title displayed during social sharing. |

CampignInfo
  • Represents the data structure of activity information in App Linking.

| Field | Type | Description | | ------- | ------ | ---------------- | | medium? | string | Activity medium. | | name? | string | Activity name. | | source? | string | Activity source. |

AndroidLinkInfo
  • Represents the data structure of Android app information in App Linking.

| Field | Type | Description | | ------------------- | ------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | androidPackageName? | string | Constructor required when a link of App Linking needs to be opened in the app with the specified APK name. This constructor is reserved and not supported currently. | | androidDeepLink? | string | Deep link to an Android app. | | androidOpenType? | AppLinkingAndroidLinkInfoAndroidOpenTypeConstants | Action triggered when the link of an Android app is tapped but the app is not installed. | | androidFallbackUrl? | string | Custom URL to be accessed when the app is not installed. |

iosLinkInfo
  • Represents the data structure of iOS app information in App Linking.

| Field | Type | Description | | ---------------- | ------ | ------------------------------------------------------ | | iosDeepLink? | string | Deep link to an iOS app. | | iosFallbackUrl? | string | Deep link to an iOS app. | | iosBundleId? | string | Bundle ID of an iOS app. | | ipadFallbackUrl? | string | URL to be accessed when the iPad app is not installed. | | ipadBundleId? | string | Bundle ID of an iPad app. |

iTunesConnectCampaingnInfo
  • Represents the data structure of App Linking iTunesConnect campaign info.

| Field | Type | Description | | ---------------------------- | ------ | --------------------------------- | | iTunesConnectProviderToken? | string | Provider token of iTunesConnect. | | iTunesConnectCampaignToken? | string | Campaign token of iTunesConnect. | | iTunesConnectAffiliateToken? | string | Affiliate token of iTunesConnect. | | iTunesConnectMediaType? | string | Media type of iTunesConnect. |

AppLinkingWithInfo
  • Represents the data structure of App Linking information.

| Field | Type | Description | | --------------------------- | ------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------- | | socialCardInfo? | SocialCardInfo | Represents the data structure of social sharing identifier information in App Linking. | | campignInfo? | CampignInfo | Represents the data structure of activity information in App Linking. | | androidLinkInfo? | AndroidLinkInfo | Represents the data structure of Android app information in App Linking. | | iosLinkInfo? | iosLinkInfo | Represents the data structure of iOS app information in App Linking. | | iTunesConnectCampaingnInfo? | iTunesConnectCampaingnInfo | iTunesConnect campaign parameters. | | expireMinute? | number | Validity period of a short link, in minutes. By default, a short link is valid for two years, and the minimum validity period is 5 minutes. | | previewType? | AppLinkingLinkingPreviewTypeConstants | Preview page style of a link of App Linking. | | uriPrefix? | string | Domain name provided by AppGallery Connect for free. | | longLink? | string | Long link to be set. | | deepLink? | string | Deep link is the URL of your app content. | | shortAppLinkingLength | ShortAppLinkingLengthConstants | Specifies whether the string-type suffix of a short link is long or short. |

Constants

ShortAppLinkingLengthConstants
  • Specifies whether the string-type suffix of a short link is long or short. This class is used to create a short link.

| Field | Type | Description | | ----- | ------ | -------------------------------------------------------------------------------------------- | | SHORT | string | A short link uses a short string-type suffix containing four or more characters as required. | | LONG | string | A short link uses a long string-type suffix containing 17 characters. |

AppLinkingLinkingPreviewTypeConstants
  • Preview page style of a link of App Linking.

| Field | Type | Description | | ----------- | ------ | ---------------------------------------------------------------------------------- | | APP_INFO | string | Displays the preview page with app information. | | SOCIAL_INFO | string | Displays the preview page with the card of a link displayed during social sharing. |

AppLinkingAndroidLinkInfoAndroidOpenTypeConstants
  • Action triggered when a link is tapped but the target app is not installed.

| Field | Type | Description | | ------------ | ------ | ---------------------------------------------------------- | | APP_GALLERY | string | Displays the app details page on AppGallery. | | LOCAL_MARKET | string | Displays the app details page in local app market. | | CUSTOM_URL | string | Displays the app details page using the fallbackUrl field. |

Events
  • Events constants for event callbacks.

| Field | Type | Description | | ------------ | ------ | --------------------------------------- | | RECEIVE_LINK | string | Listens on receive link of App Linking. |


4. Configuration and Description

Preparing for Release

Before building the APK, configure obfuscation scripts to prevent the AppGallery Connect SDK from being obfuscated. If obfuscation arises, the AppGallery Connect SDK may not function properly.

NOTE: This step is required only if you want to minify and obfuscate your app. By default obfuscation is disabled in Cordova and Ionic apps.

The obfuscation is done by ProGuard. By default, in Cordova and Ionic apps ProGuard is disabled. Even though ProGuard is not available, ProGuard support can be added through 3rd party ProGuard plugins. If ProGuard is enabled in your project, the Huawei Cordova App Messaging Plugin's ProGuard rules need to be added to your project. These rules are as follows:

-ignorewarnings
-keepattributes *Annotation*
-keepattributes Exceptions
-keepattributes InnerClasses
-keepattributes Signature
-keep class com.huawei.hianalytics.**{*;}
-keep class com.hianalytics.android.**{*;}
-keep class com.huawei.updatesdk.**{*;}
-keep class com.huawei.hms.**{*;}
-keep class com.huawei.agconnect.**{*;}
-keep class com.huawei.agc.**{*;}
-repackageclasses

Enabling the App Linking Service

  1. Sign in to AppGallery Connect and click My projects.
  2. Find your project from the project list and click the app for which you need to enable App Linking on the project card.
  3. Go to Growing > App Linking. On the App Linking page that is displayed, click Enable now.

Create App Linking URL Prefix

  • A URL prefix is a URL contained in a link. To uniquely identify the URL prefix, you need to prefix the free domain name (for example, drcn.agconnect.link or dre.agconnect.link) provided by AppGallery Connect with a string
  1. Sign in to AppGallery Connect and click My projects.
  2. Find your project from the project list and click the app for which you need to create a link of App Linking on the project card.
  3. Go to Growing > App Linking and click the URL prefix tab.
  4. Click Add URL prefix and set a unique URL prefix, which can contain only lowercase letters and digits.
  5. Click Next. A message is displayed, indicating that the URL has been verified.

Accessing Analytics Kit

To use analytics feature,

  • Navigate into your <cordova_project_root_directory>/platforms/android/app/build.gradle and add build dependencies in the dependencies section.

    dependencies {
        implementation 'com.huawei.hms:hianalytics:5.1.0.301'
    }
  • Navigate into your <cordova_project_root_directory>/platforms/ios file and edit the Podfile file to add the pod dependency 'HiAnalytics'

    • Example Podfile file:

      # Pods for AGCAppLinkingDemo
      pod 'HiAnalytics'
    • Run pod install to install the pods.

      $ pod install
    • Initialize the Analytics SDK using the config API in AppDelegate in iOS platform.

      Sample code for initialization in AppDelegate.m:

      #import "AppDelegate.h"
      #import <HiAnalytics/HiAnalytics.h>
      
      @implementation AppDelegate
      ...
      // Customize the service logic after app launch.
      - (BOOL)application:(UIApplication*)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions {
        self.viewController = [[MainViewController alloc] init];
      // Initialize the Analytics SDK.
      [HiAnalytics config];   
       return [super application:application didFinishLaunchingWithOptions:launchOptions];
      }
      ...
      @end

    For further information please refer to Analytics Kit Service Guide.


5. Sample Project

You can find the sample projects on AppGallery Connect > Examples > AppLinking > Framework page.


6. Licencing and Terms

Huawei AppLinking SDK Plugin is licensed under Apache 2.0 license