How To Make Your Own Apps
1. System Requirements
Make sure that the computer being used for development meets the software and hardware requirements for the Android SDK and Eclipse.
http://developer.android.com/sdk/requirements.html
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
2.Installation and Configuration
2.1 Download and Configure Eclipse IDE
Eclipse is the preferred development environment for Android. You can download eclipse at http://www.eclipse.org/downloads/ . It is recommended that you install either classic or the Java Version of eclipse.
2.2 Download Android SDK
1. Go to http://developer.android.com/sdk/index.html and click on the Windows installer.
2. This should automatically check to see if you have the proper JDK installed. If you do not you can download the newest JDK here:
http://www.oracle.com/technetwork/java/javase/downloads/index.html
2.3 Install ADT plugin for eclipse
1. Open Eclipse and go to Help->Install new Software.
2. Enter https://dl-ssl.google.com/android/eclipse/ in the Work with box.
3. Then put a check mark next to the Developer Tools and click Next.
4. On the next screen it will show all of the tools that will be downloaded. Click Next.
5. Read and agree the license agree to the license agreements then click Finish.
6. Restart Eclipse.
2.4 Configure the ADT plugin.
After installing the ADT it will need to be configured to point to the SDK directory.
1. Click on Window->Preferences->Android.
2. Click on Browse to find the location of your SDK directory.
3. Click Apply, and then OK.
2.5 Adding SDK Components.
1. Click on Window->Android SDK Manager.
2. This will allow you to choose the Android platform versions, add-ons tools and other components. Choose the version of Android that you would like you application to work on. Note: This application note will be using 2.3.3.
3. Click Install Selected and wait for the components to down. When the download is finished, verify and accept the new components.
2.6 Create an AVD
1. In Eclipse go to Window->AVD Manager->New.
2. Type in the Name of the AVD and choose a Target. The target is the version of the Android SDK that you would like to run on the emulator.
3. Click Create AVD.
3 Create a new Android Application
1. In Eclipse go to File->New->Project…
2. Select an Android Project from the Android Folder and press Next.
3. Fill in the details of your Android application.
a. Project Name: The project name and folder that Eclipse will store the project files
b. Build Target: The version of the Android SDK that will be used when you build your program. Select a platform that is equal to or lower than the target chosen for the AVD.
c. Application Name: This is the name of the application.
d. Package Name: The namespace that all of the source code will reside under.
e. Create Activity: The name for that class stub that is generated by the plugin.
4. The values that are used in this example are:
a. Project Name: SampleApp
b. Build Target: 2.3.3
c. Application Name: SampleApp
d. Package Name: com.sample.example
e. Create Activity: SampleApp
5. Click on Finish.
4 Coding the Application
4.1 Changing the text
1. Open strings.xml which is located in res->values->string.xml. This file will hold all of the text that our layout will use.
a. Click on the strings.xml at the bottom to bring up the raw xml file.
b. Using the current string xml format change the xml to include
i. Name: name String: Please type your name.
ii. Name: app_name String: Hello User
c. Your xml file should look like:
4.2 Editing the layout
2. Open main.xml which is located in res->layout->main.xml. This file will hold the layout of the application which includes labels, textboxes, and other UI interfaces.
a. Main.xml has a GUI and a raw xml view. The GUI has many different widgets that you can drag and drop onto the screen.
b. From the form widgets drag a Large text label and from Text Fields drag the first and last name text box onto the phone screen.
c. Then go to the raw xml view and add android:text=”@string/name” to the TextView. You can see the final raw xml below. This will take the text that is labeled “name” in the strings.xml and display it for the TextView.
4.3 Editing the the java code
1. Open SampleApp.java from the left hand side.
2. At the top add the following import statements
b. This allows you to use the functions located in these files.
3. Next we need to add the code to get the information from the text box and display it. The following code gets the name from the text box and forms it into a string that says “Hello [name]”. Then it uses the the toast class to display the message to the user when enter is pressed. Enter the following code at the end of onCreate.
4. Save the file
5 Running the Application
1. Click on the green circle with the white arrow.
2. Choose the AVD that we created in a previous step.
3. The android AVD will load and the program will run.
You have successfully completed an android application :good::good: .
Reserved
Tnx bro.gonna try dis
Awesome... will be trying this out soon... i have a few idea's i wanna try out
Guide is good bro...but how to create a better or a bit advanced app??
Related
More information like this, you can visit HUAWEI Developer Forum
This post is an introduction to Azure release pipeline using AGC publish API, In this walkthrough I’ll lay out the general steps on how to setup your Azure DevOps pipeline in such a way that a single click will trigger a new AppGallery app release.
summary
We will create a pipeline that executes the gradle task to generate an apk and sign it. We create a connection to the repository containing our android project. We will then integrate AGC publish API using python to deploy the APK to AppGallery.
Requirements
I will assume that you already have a working Android app released on AppGallery and have the following:
AppGallery account
Microsoft Azure account
Android project hosted in a remote repo (azure repo, github, bitbucket...)
Setting up CI
Configure Gradle to sign generated APK:
Copy the signature file generated in Generating a Signing Certificate Fingerprint to the app root directory and configure the signature in the build.gradle file in the project directory
Code:
signingConfigs {
release {
storeFile file('xxx.xxx')
keyAlias 'xxxx'
keyPassword 'xxxx'
storePassword 'xxxx'
}
}
buildTypes {
release {
signingConfig signingConfigs.release
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
debug {
signingConfig signingConfigs.release
}
}
Create new release pipeline:
Go to azure release pipelines page, then click on New->New release pipeline
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
You will see pipeline template selection page:
Here, we will not pick and existing template, we will click on Empty Job:
Our pipeline is now ready to be developed
Add artifact (link repo)
Our project is hosted on Github, you can host your project on any repository management service, we recommend Azure repos, github or bitbucket.
To link the repo, we have to click on the add button in next to artifacts as shown here:
We will create a connection to github, click on new button, name the connection then click on Authorize using OAuth, new Github window will pop up asking to give azure permission.
to select the repo. We click on the three dots button to browser our repos
Now we pick our android project repo
We then chose branch, version and set an alias name for the artifact as shown in the next screenshot:
Click Add button then we add tasks
Add tasks
To add add a task you need to click on the plus icon on the agent as follow:
Task 1: Use python version:
This task is to select python version to run our scripts
Add new task, on the sidebar search for “use python version”, hover over the first task and click on add, leave the default information, it should be version 3.x
Task 2: Gradle assembleRelease
We add this task to run gradle script to make a build (generate apk)
Click on add task icon, then search and add Gradle task:
We select the gradle wrapper by clicking on the three dots icon:
Now select the gradlew.bat from the dialog that pops up
now let’s select the working directory by clicking on three dots icon next to working directory input and select the root folder of the project and click OK
See the scripts, we will create a release apk therefore write, assembleRelease in Gradle tasks. You can as well write assembleDebug if you want to generate a debug apk, also we choose not to publish Junit test results (under gradle tasks)
Task 3: copy generate APK
We add a task to copy the generate apk into an azure special directory to prepare to upload it to AppGallery, click on add tasks button and search for “Copy Files”
Set the Contents input to **/*.apk and the Target Folder input to: $(build.artifactStagingDirectory) as shown:
Task 4: pip install request
We install request module to use it in out python scripts
Click on the add task button and search for “Command line” and add it
Give the task and meaningful name, and add the following script:
Code:
cd C:\hostedtoolcache\windows\Python\3.8.1\x64\Scripts
pip install requests
Note: We will follow AGC publish API documentation to upload the apk to AppGallery which will be done using 5 tasks
you don’t need to change the code in this post as we are using variables, which we will add in a later step
Task 5: Get AppGallery access token
First we need to get access token to use AGC Publish API
Click on add task button and search for “Python script”, give the task a name, select inline, then add the following python script:
Code:
import requests
json_data = {"client_id":"$(client_id)","client_secret":"$(client_secret)","grant_type":"client_credentials"}
req = requests.post("https://connect-api.cloud.huawei.com/api/oauth2/v1/token",json=json_data)
res_data = req.json()
res_data = "Bearer " + res_data['access_token']
print("##vso[task.setvariable variable=access_token]"+res_data)
This is not the end. For full content, you can visit https://forums.developer.huawei.com/forumPortal/en/topicview?tid=0202337168449920057&fid=0101187876626530001
According to the introduction of Cocos Creator from its official website, Cocos Creator 2.4.1 and later versions support HUAWEI AppGallery Connect and have been providing multiple AppGallery Connect services. The following figure shows all supported AppGallery Connect services.
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
To test how well Cocos supports AppGallery Connect services, this article uses the App Performance Management (APM) service as an example to monitor the performance data of a Cocos-developed app. First, let's see what APM is.
AppGallery Connect APM
APM of AppGallery Connect provides minute-level app performance monitoring capabilities. You can view and analyze app performance data collected by APM in AppGallery Connect to comprehensively understand the performance features of developed apps, helping you quickly and accurately rectify possible performance problems and continuously improve user experience.
That is, APM can help you monitor your app performance data in a variety of scenarios, including app launch, page loading, and network request. We can assume that APM can quickly locate performance-related problems for games, which attach great importance to performance as it greatly affects user experience.
Before You Start
Downloading and Installing the Cocos Dashboard
1. The Cocos Dashboard is the GUI-based development tool provided by Cocos. You can download it from https://www.cocos.com/creator/ (latest version: 2.4.2).
2. You need to install the Visual Studio as well to obtain the Cocos dependency package. The following figure shows the installation procedure.
3. After the installation is complete, click Run
Downloading and Installing Cocos Creator
1. Open the Cocos Dashboard and click Signin in the upper right corner. You can sign up first if you do not have an account.
2. After sign-in, click Editor on the left, and then click Download in the lower right corner.
3. On the Editor page, select the latest version of Cocos Creator, click the download button on the right, and agree with the terms.
4. Once the download is complete, you can create a Cocos project on the Project page. Take a HelloWorld project as an example.
5. When you open the project for the first time, the system prompts you to select a language. Just select English. Select the corresponding running environment and click Run.
Configuring the Visual Studio Code Compilation Environment
The built-in code editor of Cocos is too simple and is only suitable for code viewing and a small amount of editing. Therefore, we need a more mature and powerful compilation environment. This is where Visual Studio Code comes in.
1. Download and install Visual Studio Code of the required version based on your computer environment.
2. Open your project in Cocos Creator and choose Developer > VS Code Workflow > Install VS Code Extension from the main menu to add an adaptation plug-in to Cocos Creator.
3. If the information shown in the following figure is displayed, the installation is successful.
4. If you want the system to autocomplete the Cocos Creator engine API during coding, you need to generate the API autocompletion data and put the data in the project path through the menu. Choose Developer > VS Code Workflow > Update VS Code API Source.
5. Double-click the HelloWorld.js script in the project directory. In the dialog box that is displayed, click Yes and select Visual Studio Code as the default editor.
6. Double-click the HelloWorld.js script again to develop your app.
Packaging and Releasing a Cocos-based App in AppGallery Connect
Cocos Creator 2.4.1 and later versions allow you to package and release your app to HUAWEI AppGallery through AppGallery Connect. In addition, Cocos Creator suports various AppGallery Connect services, such as APM, which can be quickly integrated and used. The detailed procedure is as follows:
1. Sign in to AppGallery Connect and create an app.
2. Sign in to Cocos Creator, choose Project > Build…, and select HUAWEI AppGallery Connect as the release platform.
3. Click Build. If Built huawei-agc successfully is displayed, the build is successful.
Note: When you build a project for the first time, you need to choose File > Settings… and configure the Android SDK path and NDK path on the native development environment page.
4. Click Compile and wait until the compilation is successful.
5. A jsb-default or jsb-link directory (depending on the template selected on the Build… panel) is generated in the build directory of the default release path. AppGallery Connect services are automatically integrated in the directory. Open the publish directory in the jsb-link directory to view the generated APK file.
6. Upload the packaged APK file locally or using AppGallery Connect.
l Uploading the file on the Upload... panel.
a) Login Type: OAuth
Click Confirm, sign in to your HUAWEI ID (with sufficient permissions), and select the check box of the corresponding permissions. The APK file will be uploaded automatically.
b) Login Type: API Client
Sign in to AppGallery Connect to obtain related configuration. Go to Users and permissions > Connect API > Create, create an API client, select a role as required, and click OK.
Enter your client ID and key of the API client in the text boxes on the Upload... panel in Cocos Creator. Click Confirm.
After the APK file is uploaded successfully, you can view it in AppGallery Connect.
Uploading the file in AppGallery Connect
Click Upload and select the APK generated by Cocos Creator.
For more details, please refer to:
Cocos official documents
AppGallery Connect APM development guide
AppGallery Connect console
GitHub to download demos and sample codes
Stack Overflow to solve any integration problems
According to the introduction of Cocos Creator from its official website, Cocos Creator 2.4.1 and later versions support HUAWEI AppGallery Connect and have been providing multiple AppGallery Connect services. The following figure shows all supported AppGallery Connect services.
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
To test how well Cocos supports AppGallery Connect services, this article uses the App Performance Management (APM) service as an example to monitor the performance data of a Cocos-developed app. First, let's see what APM is.
AppGallery Connect APM
APM of AppGallery Connect provides minute-level app performance monitoring capabilities. You can view and analyze app performance data collected by APM in AppGallery Connect to comprehensively understand the performance features of developed apps, helping you quickly and accurately rectify possible performance problems and continuously improve user experience.
That is, APM can help you monitor your app performance data in a variety of scenarios, including app launch, page loading, and network request. We can assume that APM can quickly locate performance-related problems for games, which attach great importance to performance as it greatly affects user experience.
Before You Start
Downloading and Installing the Cocos Dashboard
The Cocos Dashboard is the GUI-based development tool provided by Cocos. You can download it from (latest version: 2.4.2).
2. You need to install the Visual Studio as well to obtain the Cocos dependency package. The following figure shows the installation procedure.
3. After the installation is complete, click Run
Downloading and Installing Cocos Creator
1. Open the Cocos Dashboard and click Signin in the upper right corner. You can sign up first if you do not have an account.
2. After sign-in, click Editor on the left, and then click Download in the lower right corner.
3. On the Editor page, select the latest version of Cocos Creator, click the download button on the right, and agree with the terms.
4. Once the download is complete, you can create a Cocos project on the Project page. Take a HelloWorld project as an example.
5. When you open the project for the first time, the system prompts you to select a language. Just select English. Select the corresponding running environment and click Run.
Configuring the Visual Studio Code Compilation Environment
The built-in code editor of Cocos is too simple and is only suitable for code viewing and a small amount of editing. Therefore, we need a more mature and powerful compilation environment. This is where Visual Studio Code comes in.
1. Download and install Visual Studio Code of the required version based on your computer environment.
2. Open your project in Cocos Creator and choose Developer > VS Code Workflow > Install VS Code Extension from the main menu to add an adaptation plug-in to Cocos Creator.
3. If the information shown in the following figure is displayed, the installation is successful.
4. If you want the system to autocomplete the Cocos Creator engine API during coding, you need to generate the API autocompletion data and put the data in the project path through the menu. Choose Developer >
VS Code Workflow > Update VS Code API Source.
5. Double-click the HelloWorld.js script in the project directory. In the dialog box that is displayed, click Yes and select Visual Studio Code as the default editor.
6. Double-click the HelloWorld.js script again to develop your app.
Packaging and Releasing a Cocos-based App in AppGallery Connect
Cocos Creator 2.4.1 and later versions allow you to package and release your app to HUAWEI AppGallery through AppGallery Connect. In addition, Cocos Creator suports various AppGallery Connect services, such as APM, which can be quickly integrated and used. The detailed procedure is as follows:
1. Sign in to AppGallery Connect and create an app.
2. Sign in to Cocos Creator, choose Project > Build…, and select HUAWEI AppGallery Connect as the release platform.
3. Click Build. If Built huawei-agc successfully is displayed, the build is successful.
Note: When you build a project for the first time, you need to choose File > Settings… and configure the Android SDK path and NDK path on the native development environment page.
4. Click Compile and wait until the compilation is successful.
5. A jsb-default or jsb-link directory (depending on the template selected on the Build… panel) is generated in the build directory of the default release path. AppGallery Connect services are automatically integrated in the directory. Open the publish directory in the jsb-link directory to view the generated APK file.
6. Upload the packaged APK file locally or using AppGallery Connect.
Uploading the file on the Upload… panel.
a) Login Type: OAuth
Click Confirm, sign in to your HUAWEI ID (with sufficient permissions), and select the check box of the corresponding permissions. The APK file will be uploaded automatically.
b) Login Type: API Client
Sign in to AppGallery Connect to obtain related configuration. Go to Users and permissions > Connect API > Create, create an API client, select a role as required, and click OK.
Enter your client ID and key of the API client in the text boxes on the Upload… panel in Cocos Creator. Click Confirm.
After the APK file is uploaded successfully, you can view it in AppGallery Connect.
Uploading the file in AppGallery Connect
Click Upload and select the APK generated by Cocos Creator.
great
It's very useful. Recently, our Cocos project is focusing on Huawei AppGallery.
Environment for Game Release and Testing
1. Have a Huawei mobile phone ready.
2. Connect that mobile phone to a PC using a data cable, and make sure that it remains connected during the game release.
The reason is that a Huawei quick game will not generate a QR code for release, so the data cable is needed during the release process. Otherwise, only one RPK package will be generated during game release in the LayaAir IDE, and you still need to connect the two devices and copy the RPK package to the mobile phone.
3. Install Node.js 10.x. You can download it here: https://nodejs.org/download/release/latest-v10.x/.
4. Install the LayaAir 2.8.1 IDE, or a later version. You can download it here: https://ldc2.layabox.com/layadownload/?type=layaairide.
Preparations
To ensure that your game release goes as smoothly as possible, make sure that you:
1. Have installed Node.js and LayaAir IDE on your PC. You do not need to install the ADB and OpenSSL, as they are built into the LayaAir IDE.
2. Have enabled the developer mode on your mobile phone, and allowed for USB debugging.
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
If you do not know how to enable the developer mode, you can check Huawei’s documentation at https://developer.huawei.com/consumer/en/doc/quickapp-open-developer-option.
Releasing a Huawei Quick Game in the LayaAir IDE
First, use the release function for the LayaAir IDE to package the Huawei quick game project to an RPK file. Then, open this project in the IDE and go to Project > Release. Select the release platform huawei fast game and set Minimum platform version(1075). Lastly, click publish to release your quick game.
I won’t describe the steps required for release in detail here. If you have any questions, please refer to the official website.
About the Certificate Fingerprint
If the release signature has been generated in the project, you can print the signing certificate fingerprint on the release page. This fingerprint will be used when you submit a Huawei quick game.
It’s important to note that the print button is only available after the release signature is generated. If no signature is generated, the message shown in the following figure will be displayed, indicating that the certificate does not exist.
Running and Testing the Game on a Real Device
After the game has been successfully released on LayaAir IDE, it will automatically run on the Huawei phone in full-screen mode. If you exit the game, you can also launch the Huawei Quick App Loader and tap the game name to restart the game.
Debugging the Game
No tool is available for debugging a Huawei quick game, so you’ll need to make sure that your browser supports the HTML5 version of the game. Debugging your Huawei quick game requires that you check its logs, so you’ll need to retain the default value log for the log level in LayaAir IDE, as shown in the figure below. In this case, both the LayaAir IDE logs and error logs will be recorded. If you set the log level to error, only error logs will be recorded. Both options allow you to view logs after the game’s release. If you select off, no logs will be available.
You can directly view logs on the project release page, as shown below.
You can also open another CLI on your PC to view logs by entering the following command. This method enables you to avoid keeping the IDE open for debugging for a long period.
adb logcat -s jsLog
All logs generated during runtime after the release are displayed in the CLI, as shown below.
If you would like to export logs, please use Huawei Quick App PC Assistant.
FAQs
1. Do Huawei quick games support package splitting?
Splitting the package of a Huawei quick game and loading its subpackages helps reduce the traffic and time required for app downloads. When doing so, you can choose to load or download specific subpackages, rather than the entire package.
Before using this method, you’ll need to determine whether this method is necessary for your project. Most quick game packages are small enough that they do not necessarily require splitting. You can opt to:
(1) Delete unnecessary JavaScript code.
If the package is not split, the JavaScript files referenced in the index.js and HTML files are packaged in the last RPK file, unless these JavaScript files are referenced elsewhere in the project. You can also directly delete the unused JavaScript files, for example, those of unused engine libraries and third-party class libraries, to reduce the package size.
(2) Compress and obfuscate JavaScript files.
This can significantly reduce the file size. If the file size does not exceed 4 MB, you won’t need to split the package, as game content can be dynamically loaded through URLs. After the content is loaded for the first time, it is stored in the physical cache. Common content that occupies less than 50 MB will not be reloaded the next time.
2. When a third-party library, for example, protobuf, is introduced, the gameThirdScriptError error is reported. What should I do?
A potential cause is that the library contains such code as Function(“return this”)();. For security purposes, the game engine disables such code by default. It is recommended that you modify the JavaScript code. In addition to protobuf, the following third-party libraries have similar code. If these libraries need to be introduced, you’ll need to modify the code as well.
If you do not modify the code, you’ll need to enable the runGame parameter, which is not recommended.
For more information, please refer to:
Huawei Quick App PC Assistant materials:
https://developer.huawei.com/consum...ickApp-Guides/quickapp-pcassistant-user-guide
Huawei quick game materials:
https://developer.huawei.com/consum...uickApp-Guides/quickgame-develop-runtime-game
My app has recently needed to use cross-platform sharing links and fortunately App Linking in AppGallery Connect exactly meets my requirements.
Perform the following steps for service integration:
i. Create an app and enable App Linking for the app.
ii. Create a URL prefix.
iii. Integrate the App Linking SDK into the Xcode project.
iv. Create a link of App Linking.
v. Receive and test the link.
1. Creating an App and Enabling App Linking for the AppCreate an app or use an existing app in AppGallery Connect. Click My projects and go to Grow > App Linking, and click Enable now in the displayed page.
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
Go to My projects > Project settings > General information, download the agconnect-services.plist file, and save the file to the directory of your Xcode project.
2. Creating a URL PrefixOn the displayed App Linking service page, click the URL prefix tab and then click Add URL prefix to create a unique URL prefix.
The system will automatically check uniqueness of your domain name.
3. Integrating the App Linking SDK into Your Xcode Project1. Open the CLI and navigate to the location of the Xcode project.
2. Run the pod init command to create a Podfile.
3. Open the Podfile and add the pod on which the AppGallery Connect base SDK depends to the Podfile.
Code:
pod 'AGConnectCore'
pod 'AGConnectAppLinking'
4. Run the pod install command to install the pod.
5. Do as follows to initialize the AppGallery Connect SDK: Import the header file <AGConnectCore/AGConnectCore.h> to the AppDelegate.m file of the project,
and add the following code to the applicationUIApplication *)application didFinishLaunchingWithOptionsNSDictionary *)launchOptions method:
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;
}
4. Creating a Link of App LinkingYou can create a link of App Linking in AppGallery Connect or call an API in your Xcode project.
4.1 Creating a Link of App Linking in AppGallery Connect1. On the displayed App Linking service page, click the App Linking tab and create a link as prompted.
2. Complete default deep link configurations. Refer to the following example. Pay attention to the deep link configuration for Android.
3. Set Link behavior for Android to Open in app.
After the link is successfully created, you can then copy and use it.
4.2 Creating a Link Through Coding1. In the following iOS UI layout, add three button controls to create and copy links and four label controls to display the created links.
2. Declare necessary parameters.
3. Create a link.
Here, the iOS deep link is set to agckit://android/detail.
The Android deep link is set to agckit://android/detail.
4. Copy the long link and short link.
Refer to the following example for copying links:
5. Receiving a Link1. To generate an asset verification file for a domain name, set the team ID under Project settings in AppGallery Connect. (The team ID is the value of Membership — Team ID on the Apple developer website.)
2. After the configuration is complete, an asset verification file is automatically generated for the default domain name. You can view the file at https://your_applinking_url_prefix/apple-app-site-association.
3. Set a custom scheme.
4. To set the code for receiving links, open the AppDelegate.m file and add the handleAppLinking method to the system startup method to process received link events.
5. Check whether the received link is a link of App Linking and whether the app can process the link.
For a custom scheme link:
Call sharedInstance of App Linking in the application: openURL: options: method to obtain a singleton object, and call openDeepLinkURL of the object to process the received link.
6. Packaging and Testing1. Verify the link creation.
Tap CreatLink. A long link and a short link are generated.
2. Verify the function of starting an app through a link.
Click CopyShortLink and copy the link to the browser. An app can be started when you access the link.
7. SummaryIntegration is simple. The SDK is small, and links can be shared across Android and iOS. No adaptation is required on different platforms, thereby reducing the workload.
Operations personnel can create links in AppGallery Connect for app promotion, and you can write code in apps to create links in a very convenient process.
For more information, please refer to:
HUAWEI AppGallery Connect App Linking documentation: https://developer.huawei.com/consum...ry-connect-Guides/agc-applinking-introduction
Nice thread
Useful and simple.
Abo Hoor said:
Nice thread
Click to expand...
Click to collapse
Thank you for your liking.
Rebis said:
Useful and simple.
Click to expand...
Click to collapse
Thanks