HarmonyOS SDK Integration Guide
Usage Tips
This document is the standard integration guide for the JMLink HarmonyOS SDK.
The supported SDK version is v1.0.0 and later.
- If you want to quickly test, please refer to this document to run through the Demo in a few minutes.
- The JiGuang MagicLink documentation website contains all related guides, APIs, tutorials, and other documentation. Updated versions of this document will also be published to that website in a timely manner.
Product Description
JiGuang MagicLink provides developers with capabilities such as link launching, parameter pass-through, and scene restoration, making it easy to handle business scenarios like activity engagement, invitation sharing, and content navigation within the App.
Main Scenarios
- Scheme Launch
- App Linking Launch
- Link Parameter Pass-through
- Scene Restoration
Obtaining Application Information
After creating an application on the console, you can navigate to the MagicLink configuration page to obtain the AppKey used to identify the application.
Integration Methods
ohpm Automatic Integration
"dependencies": {
"@jg/mlink": "^1.0.0" // Set up JiGuang MagicLink automatic integration
}
Manual Integration
Contents of jmlink-hmos-x.x.x-release.zip Integration Package
jmlink-hmos-x.x.x-release.har
- JiGuang MagicLink HarmonyOS SDK core package.
doc
- Documentation
entry
- A HarmonyOS demo project that demonstrates the basic usage of the JMLink SDK, which can be used as a reference.
HAR File Integration
- Extract the jmlink-hmos-x.x.x-release.zip integration package.
- Copy jmlink-hmos-x.x.x-release.har to the entry/hars/ directory of your project. (The hars directory name can be customized)
Note: To link jmlink-hmos-x.x.x-release.har, for example, if you copy the har to the entry/hars/ directory, add the following to the oh-package.json5 file under the entry module:
"dependencies": {
"@jg/mlink": "./hars/jmlink-hmos-x.x.x-release.har" // The path here is where you stored jmlink-hmos-x.x.x-release.har
}
Configure Permissions
Configure the permissions required by MagicLink in module.json5:
"requestPermissions": [
{
"name": "ohos.permission.INTERNET"
},
{
"name": "ohos.permission.GET_NETWORK_INFO"
}
],
Configure JiGuang Platform Information
The main steps are:
- Create an App on the JiGuang platform and obtain the package name and AppKey
Note:
Configure the package name in the local project by adding the following to the app.json5 file under the AppScope directory:
{
"app": {
"bundleName": "your.package.name",
}
}
Configure Scheme Launch
If you need to launch the application via Scheme, configure the viewData skill in the target Ability of entry/src/main/module.json5.
"skills": [
{
"entities": [
"entity.system.browsable"
],
"actions": [
"ohos.want.action.viewData"
],
"uris": [
{
"scheme": "mlinkdemo",
"host": "open",
"pathStartWith": "/home"
}
]
}
]
Example link:
mlinkdemo://open/home?from=test
Configure App Linking Launch
If you need to launch the application via an https link, configure the https-type viewData skill in the target Ability of entry/src/main/module.json5 and enable domainVerify.
"skills": [
{
"entities": [
"entity.system.browsable"
],
"actions": [
"ohos.want.action.viewData"
],
"uris": [
{
"scheme": "https",
"host": "applink.example.com",
"pathStartWith": "/mlink"
}
],
"domainVerify": true
}
]
Example link:
https://applink.example.com/mlink?from=test
Both the server side and the console need to complete the following configurations. For AppGallery Connect configuration requirements, please refer to the official documentation:
https://developer.huawei.com/consumer/cn/doc/harmonyos-guides/app-linking-kit-guide
- Enable the App Linking capability on the console.
- Configure the https domain or URL prefix for launching the application on the console.
- Configure the domain verification file on the domain side as required by HarmonyOS App Linking.
- Ensure the domain, package name, and current application configuration are consistent.
Other Features
Please refer to: HarmonyOS SDK API Reference
Running the Demo
The demo included in the package is an API demonstration example. You can import it into your project, configure your AppKey, package name, Scheme, and App Linking domain, and then run it directly to test.
Technical Support
Email: support@jiguang.cn