Cordova AGC App Linking: Sample Cordova Project
Introduction
Hi everyone, this article provides usage of AppGallery Connect App Linking for Cordova mobile application. First of all, I would like to talk about the possibilities that AGC App Linking provides.
About AGC App Linking
App Linking allows you to create cross-platform links that can work as defined regardless of whether your app has been installed by a user. A link created in App Linking can be distributed through multiple channels to users. When a user taps the link on an Android or iOS device, the user will be redirected to the specified in-app content.
To identify the source of a user, you can set tracing parameters for various channels when creating a link of App Linking to trace traffic sources. By analyzing the link performance of each traffic source based on the tracing parameters, you can find the platform that can achieve better promotion effect for your app.
When a link is tapped, an action will be triggered based on the link opening mode that you have specified and whether the user has installed your app.
A link can be opened either in a browser or in your app, which is specified by you.
- If you set the link as to be opened in a browser, a user can open the link in a browser either from a mobile device or PC.
- If you set the link as to be opened in your app, when a user who has not installed the app taps the link, the user will be redirected to AppGallery (or a custom address) and instructed to install your app. After the user installs the app, the app will be launched and the in-app content will be displayed.
- If a user who has installed your app taps the link, the user will be directly redirected to the target in-app content.
Integrating AGC App Linking Plugin
Creating an AppGallery Connect Project
A project is a container of your apps in AppGallery Connect. You can add different platform versions of an app to the same project. Before creating an app, create a project in AppGallery Connect first.
1. Sign in to AppGallery Connect and select My projects.
2. Click Add project.
3. Enter a project name and click OK.
4. After the project is created, the Project settings page is displayed. You need to add an app to the project.
Adding an App to the Project
Before you use development capabilities provided by AppGallery Connect, you need to add an app to your project first.
- Sign in to AppGallery Connect and select My projects.
- Click your project from the project list.
- Go to Project settings > General information, and click Add app.
4. On the Add app page, enter app information.
5. On the Project settings page, download the configuration file agconnect-services.json and agconnect-services.plist.
7. Package name set in config.xml file.
Cordova Sample Project Using Cordova AGC App Linking Plugin
- Download the Cordova sample project from the link.
- Download the Cordova AGC App Linking Plugin from the link.
Using Cordova CLI
- Add android platform to the project with using Cordova CLI.
- Add iOS platform to the project with using Cordova CLI.
- Integrate Cordova AGC App Linking Plugin to your project with using Cordova CLI.
- Copy agconnect-services.json file to <project_root>/platforms/android/app directory your Android project.
- Add agconnect-services.plist file to the app’s root directory of your Xcode project.
- Run the Android application
- Run the iOS application
Creating a Link of App Linking
You can create a link of App Linking in any of the following modes:
- Creating a link in AppGallery Connect
- Manually constructing a link
Creating a Link in AppGallery Connect
You can apply operations in the developer guide because there isn’t special operation in the a link of App Linking creation phase with AppGallery Connect.
Manually Constructing a Link of App Linking
Prerequisites
- Enable to App Linking Service in AppGallery Connect
- Go to Grow > App Linking and click the URL prefix tab and then Add URL Prefix.
- URL Prefix like https://xyz123.dre.agconnect.link
Create Custom a Short Link
Note: Update <URI_PREFIX> at line 49.
Android receive app link: In manifast.xml file change android:host= “developer.huawei.com”
android:host indicates the domain name in the deep link.iOS recieve app link: 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.
- Social Card Info
- Campaign Info
- Android Link Info
- iOS Link Info
- App Linking With Info
- Resolved Link Data Result
Create a Short Link of App Linking and then Share a Link
Created a short link of App Linking without information such as social card info and campaign info and then shared that short link.
Launch Application From a Link of App Linking
- 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.
- Launch application from shortLink or longLink of AppLinking.
- Application will be launch and the resolvedLinkDataResult is displayed screen.
- Call addListener() function in onDeviceReady()
Conclusion
In this article, I explained what is the Cordova AGC App Linking plugin, what capabilities it provides, and how to use it in the Cordova mobile application. If you have any questions, you can write the question in the comment section.