1.2.0 • Published 3 years ago

@cordova-plugin-agconnect/applinking v1.2.0

Weekly downloads
2
License
Apache-2.0
Repository
-
Last release
3 years ago

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.
    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.
    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 TypeMethod NameDefination
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\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.

ParametersTypeDefinition
appLinkingWithInfoAppLinkingWithInfoSets information to be contained in a link of App Linking.
ReturnDefinition
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.

ParametersTypeDefinition
appLinkingWithInfoAppLinkingWithInfoSets information to be contained in a link of App Linking.
ReturnDefinition
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.

ParametersTypeDefinition
eventEventsWhich event listener will be added for.
callbackResolvedLinkDataCallback function called when the given event is triggered.
ReturnDefinition
Promise\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.
FieldTypeDescription
deepLinkstringObtains the deep link contained in a link of App Linking.
clickTimeStampnumberObtains the time when a link of App Linking is tapped.
socialTitle?stringAddress of the preview title displayed during social sharing.
socialDescription?stringPreview description displayed during social sharing.
socialImageUrl?stringAddress of the preview image displayed during social sharing.
campaignName?stringActivity name.
campaignMedium?stringActivity medium.
campaignSource?stringActivity source.
ShortLink
  • Represents the data structure of App Linking short link and test URL.
FieldTypeDescription
shortLinkstringShort app link.
testUrlstringURL for previewing the flowchart of a link of App Linking.
LongLink
  • Represents the data structure of App Linking long link.
FieldTypeDescription
longLinkstringLong app link.
SocialCardInfo
  • Represents the data structure of social sharing identifier information in App Linking.
FieldTypeDescription
description?stringPreview description displayed during social sharing.
imageUrl?stringAddress of the preview image displayed during social sharing.
title?stringAddress of the preview title displayed during social sharing.
CampignInfo
  • Represents the data structure of activity information in App Linking.
FieldTypeDescription
medium?stringActivity medium.
name?stringActivity name.
source?stringActivity source.
AndroidLinkInfo
  • Represents the data structure of Android app information in App Linking.
FieldTypeDescription
androidPackageName?stringConstructor 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?stringDeep link to an Android app.
androidOpenType?AppLinkingAndroidLinkInfoAndroidOpenTypeConstantsAction triggered when the link of an Android app is tapped but the app is not installed.
androidFallbackUrl?stringCustom URL to be accessed when the app is not installed.
iosLinkInfo
  • Represents the data structure of iOS app information in App Linking.
FieldTypeDescription
iosDeepLink?stringDeep link to an iOS app.
iosFallbackUrl?stringDeep link to an iOS app.
iosBundleId?stringBundle ID of an iOS app.
ipadFallbackUrl?stringURL to be accessed when the iPad app is not installed.
ipadBundleId?stringBundle ID of an iPad app.
iTunesConnectCampaingnInfo
  • Represents the data structure of App Linking iTunesConnect campaign info.
FieldTypeDescription
iTunesConnectProviderToken?stringProvider token of iTunesConnect.
iTunesConnectCampaignToken?stringCampaign token of iTunesConnect.
iTunesConnectAffiliateToken?stringAffiliate token of iTunesConnect.
iTunesConnectMediaType?stringMedia type of iTunesConnect.
AppLinkingWithInfo
  • Represents the data structure of App Linking information.
FieldTypeDescription
socialCardInfo?SocialCardInfoRepresents the data structure of social sharing identifier information in App Linking.
campignInfo?CampignInfoRepresents the data structure of activity information in App Linking.
androidLinkInfo?AndroidLinkInfoRepresents the data structure of Android app information in App Linking.
iosLinkInfo?iosLinkInfoRepresents the data structure of iOS app information in App Linking.
iTunesConnectCampaingnInfo?iTunesConnectCampaingnInfoiTunesConnect campaign parameters.
expireMinute?numberValidity 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?AppLinkingLinkingPreviewTypeConstantsPreview page style of a link of App Linking.
uriPrefix?stringDomain name provided by AppGallery Connect for free.
longLink?stringLong link to be set.
deepLink?stringDeep link is the URL of your app content.
shortAppLinkingLengthShortAppLinkingLengthConstantsSpecifies 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.
FieldTypeDescription
SHORTstringA short link uses a short string-type suffix containing four or more characters as required.
LONGstringA short link uses a long string-type suffix containing 17 characters.
AppLinkingLinkingPreviewTypeConstants
  • Preview page style of a link of App Linking.
FieldTypeDescription
APP_INFOstringDisplays the preview page with app information.
SOCIAL_INFOstringDisplays 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.
FieldTypeDescription
APP_GALLERYstringDisplays the app details page on AppGallery.
LOCAL_MARKETstringDisplays the app details page in local app market.
CUSTOM_URLstringDisplays the app details page using the fallbackUrl field.
Events
  • Events constants for event callbacks.
FieldTypeDescription
RECEIVE_LINKstringListens 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