blackBox directly to your server. Do not cache it on the client.blackBox in real time at key business points.Please note that when integrating the SDK product provided by TrustDecision into your app:
ohpm install @trustdecision/mobriskoh-package.json5#Add the third-party package dependency in your project's oh-package.json5:
{
"dependencies": {
"@trustdecision/mobrisk": "1.3.6"
}
}Add the following requestPermissions configuration under the module node in your project's module.json5:
"requestPermissions": [
{
"name": "ohos.permission.INTERNET"
},
{
"name": "ohos.permission.GET_NETWORK_INFO"
},
{
"name": "ohos.permission.GET_WIFI_INFO"
},
{
"name": "ohos.permission.STORE_PERSISTENT_DATA"
},
{
"name": "ohos.permission.APPROXIMATELY_LOCATION"
}
]initWithOptions only after the user has agreed to the privacy policy.public static async initWithOptions(context: Context, params: TDRiskOption): Promise<void>Execute the following code after the user has agreed to the privacy policy:
import AbilityStage from '@ohos.app.ability.AbilityStage'
import { TDRisk, TDRiskOption } from '@trustdecision/mobrisk'
export default class MyAbilityStage extends AbilityStage {
async onCreate() {
const options: TDRiskOption = {
partnerCode: 'your partnerCode', //please fill in the partnerCode, not the partnerKey
appKey: 'your appKey', // Configure AppKey, please contact the operator to obtain
dataCenter: TDRisk.DATA_CENTER_CN // Data center. See the configuration options below.
}
await TDRisk.initWithOptions(this.context, options)
}
}blackBox#getBlackBoxAsync / getBlackBox only after initWithOptions has completed.blackBox in the app. Call the corresponding method each time you need it.blackBox for the first time, and then call the synchronous method as needed after the async callback is completed./**
* Asynchronously gets the blackbox.
* @param priorityCache Whether to return the cached value first. Default is false.
* false: waits until the current data reporting is completed, then returns the latest blackbox.
* true: starts data reporting, then returns the cached blackbox first if available for immediate use.
*/
public static async getBlackBoxAsync(priorityCache: boolean = false): Promise<string>
/**
* Synchronously gets the blackbox and directly returns the current available blackbox.
*/
public static getBlackBox(): stringFor the first retrieval and at key business points, it is recommended to use the asynchronous method:
import { TDRisk } from '@trustdecision/mobrisk'
async function getBlackBox() {
const blackBox = await TDRisk.getBlackBoxAsync();
console.info('TD_TS', `async blackBox: ${blackBox}`);
}After the first asynchronous retrieval is completed, you can synchronously get it as needed at business points:
import { TDRisk } from '@trustdecision/mobrisk'
function getBlackBox() {
const blackBox = TDRisk.getBlackBox();
console.info('TD_TS', `sync blackBox: ${blackBox}`);
}blackBox in real time at key business points such as registration, login, payment, and marketing.blackBox values.TD_TS: td sdk init success in the logs.getBlackBoxAsync() is typically a normal blackBox with a fixed length of 26 characters.getBlackBoxAsync() may increase significantly. For details, refer to Differences Between Normal blackBox and Degraded blackBoxconst version: string = TDRisk.getSDKVersion()