Our application needs to use cross-platform sharing links, and huawei AppGallery Connect’s AppLinking service meets our usage scenario.

There are a lot of integration steps on the official website, so LET me summarize the steps

I. Create an application and enable the AppLinking service

Ii. Create a link prefix

Iii. Integrate the AppLinking SDK with Android projects

Iv. Create AppLinking

V. Receive AppLinking links and test.

1. Create an application and enable the AppLinking service

From the AGC console, create an app, or use an existing app, go to my Project -> Grow -> AppLinking and click Open now.

After that, go to My Project -> Project Settings -> General and download the agconnect-services.plist file to your XCode project’s project path.

After that, go to My Project -> Project Settings -> General and download the agconnect-services.plist file to your XCode project’s project path.

2. Create a link prefix

Under AppLinking, click the Link Prefix TAB, click Add Link Prefix, and create a prefix unique to the live network as required.

The system will automatically help you detect, ensure that your domain name is unique throughout the network.

3. Integrate the AppLinking SDK with iOS projects

1. Open a command line window and navigate to the Xcode project location.

2. In the COMMAND line window, run the pod init command to create the Podfile.

3. Open the PodFile file and add the POD that the AGC base SDK depends on to the podfile.

pod 'AGConnectCore'
pod 'AGConnectAppLinking'
Copy the code

4. In the command line window, run pod install to install pod.

5, initialize the AGC SDK: in the project of AppDelegate. M file to import the header file < AGConnectCore/AGConnectCore. H >,

And in the application: (UIApplication *) application didFinishLaunchingWithOptions: (launchOptions NSDictionary *) method to add the following code:

#import "AppDelegate.h"
#import <AGConnectCore/AGConnectCore.h>
@implementation AppDelegate
- (BOOL)Application:(UIApplication *)Application didFinishLaunchingWithOptions: (NSDictionary *)launchOptions {
    // Override point for customization after Application launch.
    [AGCInstance startup];  / / initialization
    return YES;
}
Copy the code

4. Create AppLinking

There are two ways to create an AppLinking app: either directly on the AGC interface, or in an Android project using code apis:

4.1 Creating an AppLinking

1. The interface entry is as follows: Click Create AppLinking and create it step by step.

2. The default deep link configuration, I just randomly found a Huawei official website. Note the configuration of Deep links on Android.

3, Android link behavior, set to: open in the Android application.

Once created, you can copy it and use it

4.2 Creating AppLinking in end-to-end Code

Add three Button controls to create and copy AppLinking. Four label controls to display the created links;

2. Declare the corresponding parameters:

3. Create a link: I set the iOS deep link as: agckit://android/detail

4. Copy the corresponding long links and short links

5. Copy links as follows

5. Receive related AppLinking

1. Generate asset verification files of domain names: the project setting interface of AGC is required to configure the corresponding Team ID (the Team ID is Apple developer website -membership — Team ID).

2. After the configuration is complete, the AGC automatically generates an asset verification file for the default domain name. You can go to https://your_applinking_url_prefix/apple-app-site-association to view the asset verification file.

3, Configure custom Schema:

4. Code Settings for receiving links: Open the appdelegate. m file and add the handleAppLinking method in the system startup method to handle the event of receiving links.

5. Determine whether the received link is an App Linking link and return whether the App can process the link.

For custom Scheme links

In the application: openURL: Options: method, call AGCAppLinking sharedInstance to get the singleton, and then call openDeepLinkURL to process the singleton

6, package test, check the phenomenon

1. Verify link creation: Click the CreatLink button to properly generate long links and short links

2. Verify that the application is pulled up through links

Click on the CopyShortLink to copy the link to your browser: Pull up the app by typing the generated AppLinking in your browser

7,

Integration is simple, SDK dependence volume is small, can achieve cross-platform sharing, Android and iOS can support, there is no need to do different adaptation in different platforms, saving work.

Operation and promotion can be created on the AGC interface, and development and sharing functions can be created with code on the side, which is perfect.

For more details, see:

Huawei AGC AppLinking service development document: developer.huawei.com/consumer/cn…


The original link: developer.huawei.com/consumer/cn…

Original author: Jessyyyyy