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.5"
}
}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",
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.
For 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();| No |
| Disables collection of ODID |
false |
options.disableODID = true |
| odid |
disableIP | No | Disables collection of IP address | false | options.disableIP = true | cellIp、wifiIp、vpnIp |
disableWifiStatus | No | Disables collection of Wi-Fi status | false | options.disableWifiStatus = true | networkType、networkNames |
disableStorageInfo | No | Disables collection of storage status | false | options.disableStorageInfo = true | totalStorage、availableStorage |
disableScreenResolution | No | Disables collection of screen resolution | false | options.disableScreenResolution = true | screenResolution |
disableBatteryInfo | No | Disables collection of battery status | false | options.disableBatteryInfo = true | batteryStatus、batteryLevelRatio、batteryPluggedType、batteryTechnology |
disableCarrierInfo | No | Disables collection of carrier information | false | options.disableCarrierInfo = true | simCountryIso、simCarrier、simState |
disablePrivacyData | No | Disables collection of privacy-related information | false | options.disablePrivacyData = true | screenResolution、deviceType、brand、marketName、batteryStatus、batteryLevelRatio、batteryPluggedType、batteryTechnology、totalStorage、availableStorage、networkType、networkNames、cellIp、wifiIp、vpnIp、simCountryIso、simCarrier、simState、latitude、longitude、altitude、gpsSwitch、bssid、ssid、odid |
httpTimeOut | No | Network request callback timeout in milliseconds | 60000 | options.httpTimeOut = 60000 | Optional |
customMessage | No | Custom message. The SDK supports passthrough and storage. | Empty | options.customMessage = 'customMessage' |