HarmonyOS
The HarmonyOS Strategy SDK is integrated as a HAR and requires DevEco Studio 5.0+ and a HarmonyOS API 12+ project environment. Complete the Analytics SDK initialization before integration.
Latest version: v1.0.0
Update time: 2026-07-24
Downloads: Download
1. Overview
Starting from AE 4.4, the Engage module provides the client-triggered task feature, which supports millisecond-level triggering in in-app scenarios such as new user registration and character creation, as well as real-time A/B splitting. On the client side, the ThinkingData SDK communicates with the AE backend to fetch and evaluate tasks.
Integrate the ThinkingData SDK into your app. On the app side, you only need to handle interactions with the ThinkingData SDK and don't need to care about task details in the AE backend.
2. Integration
2.1 Integrate the SDK with ohpm
Run the following command in the root directory of the host project (the directory that contains oh-package.json5):
ohpm install @thinkingdata/strategy
@thinkingdata/analytics and @thinkingdata/remoteconfig are declared in the dependencies of Strategy and are installed automatically with @thinkingdata/strategy, so you don't need to install them separately.
Declare the dependency in the module's oh-package.json5:
"dependencies": {
"@thinkingdata/strategy": "1.0.0"
}
2.2 Integrate the HAR manually
Client-triggered tasks depend on the following ThinkingData SDKs:
| SDK name | Description | Version requirement |
|---|---|---|
| TDAnalytics | Collects and processes data | 1.9.0 |
| TDRemoteConfig | Fetches configuration from the AE backend | 1.0.0 |
| TDStrategy | Provides client-side triggering | 1.0.0 |
- Get the HAR packages (
TDStrategy.har,TDAnalytics.har,TDRemoteConfig.har) - Put the HARs in the host project (for example,
entry/libs/) - Declare the file dependencies in
oh-package.json5:
"dependencies": {
"@thinkingdata/strategy": "file:./libs/TDStrategy.har",
"@thinkingdata/analytics": "file:./libs/TDAnalytics.har",
"@thinkingdata/remoteconfig": "file:./libs/TDRemoteConfig.har"
}
3. Initialization
Initialization order: TDAnalytics.init first, then TDStrategy.init.
Initialize the Analytics SDK:
import { common } from '@kit.AbilityKit';
import { TDAnalytics } from '@thinkingdata/analytics';
const context = getContext(this) as common.UIAbilityContext;
await TDAnalytics.init(context, 'AppId', 'ServerUrl');
TDAnalytics.login('your_client_user_id');
Initialize the Strategy SDK:
import {
TDStrategy,
TDStrategyMode,
TDStrategySettings,
} from '@thinkingdata/strategy';
const settings = new TDStrategySettings('AppId', 'ServerUrl');
settings.mode = TDStrategyMode.NORMAL;
TDStrategy.init(context, settings);
// Actively fetch the latest task configuration (optional)
TDStrategy.fetch();
4. Set a callback listener
After initializing Analytics and before calling TDStrategy.init, set a callback listener for the TDStrategy SDK.
import {
TDStrategy,
TDStrategyResult,
TDStrategyResultListener,
} from '@thinkingdata/strategy';
const listener: TDStrategyResultListener = {
onTriggerResult: (result: TDStrategyResult) => {
// A task is hit. Handle the push content here
},
};
TDStrategy.setTriggerListener(listener);
4.1 Callback data model
export class TDStrategyResult {
appId: string;
taskId: string;
channelMsgType: string;
pushId: string;
content: Record<string, Object>;
userParams: Record<string, Object>;
opsProperties: Record<string, Object>;
}
Property description
| Property name | Type | Description |
|---|---|---|
| channelMsgType | string | Channel message type |
| appId | string | The app id of your AE project |
| pushId | string | Channel send ID of the operation task |
| taskId | string | ID of the operation task |
| content | Record<string, Object> | Push content of the operation task |
| userParams | Record<string, Object> | Custom parameters in the client channel |
| opsProperties | Record<string, Object> | Channel information carried by the client-triggered task, used as receipt parameters for touch funnel events |

