Only supports Android and iOS
Integrated Requirement
Compliance Explanation
Please note that when integrating SDK products provided by the TrustDecision in the APP of your company:
1.1 According to the user's information protection regulations, before your users start the App for the first time and start collecting information, your company should fully inform the user of the purpose, method, and scope of collecting, using, and sharing the user's personal information with a third party through an interactive interface or design (such as a pop-up window of the privacy policy), and obtain the express consent of the end user.
1.2 To provide business security and risk control services to your company, the TrustDecision SDK will collect, process, and use the identification information(IMEI/IDFA), AndroidID, IMSI, MEID, MAC address, SIM card serial number, device type, device model, system type, geographical location, login IP address, application list, running process, sensor information(light sensor, gravity sensor, magnetic field sensor, acceleration sensor, gyroscope sensor) and other device information of the user's device. To ensure compliance with your use of related services, the aforementioned privacy policy should cover the authorization of TrustDecision SDK to provide services and collect, process, and use relevant information. The following terms are for your reference. The specific expression can be determined by your company according to the overall framework and content of your privacy agreement:
TrustDecision SDK: For business security and risk control, our company uses the TrustDecision SDK. The SDK needs to obtain the information of your devices, such as (IMEI/IDFA), AndroidID, IMSI, MAC address, SIM card serial number, device type, device model, system type, geographic location, login IP address, application list, running process, sensor information(light sensor, gravity sensor, magnetic field sensor, acceleration sensor, gyroscope sensor) and other related device information, for fraud risk identification.
Privacy Protocol: TrustDecision Privacy Policy
Environment
| Android | iOS | |
|---|---|---|
| Supported System Versions | Android 5.0 and above | iOS 9.0 and above |
| Supported Architectures | armeabi-v7a, arm64-v8a, x86 | armv7,arm64,x86_64 |
Integrate
Install
Plugin Install
Add trustdevice_pro_plugin to pubspec.yaml of your project.
dependencies:
flutter:
sdk: flutter
...
trustdevice_pro_plugin: ^1.4.8AndroidManifest.xml
Declare the following permissions in the AndroidManifest.xml file under the application module
<manifest>
<!-- required -->
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<!-- Outside the Chinese Mainland -->
<uses-permission android:name="com.google.android.gms.permission.AD_ID"/>
<!--optional, If not declared, some device information will be abandoned -->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<!-- required for Android 11 and above to obtain the installed packages -->
<uses-permission android:name="android.permission.QUERY_ALL_PACKAGES"
tools:ignore="QueryAllPackagesPermission" />
</manifest>Permissions
| Name | Description |
|---|---|
| INTERNET(required) | Allows the app to access the network connection and send requests to communicate with the server. |
| ACCESS_NETWORK_STATE(required) | Collect network connection status information. |
| ACCESS_WIFI_STATE(required) | Collect the current WiFi access status and WLAN hotspot information. |
| AD_ID(required) | Collect the Google advertising ID, required outside the Chinese Mainland. |
| ACCESS_COARSE_LOCATION | Get location information, with an accuracy of approximately 30 to 1500 meters. |
| ACCESS_FINE_LOCATION | Get location information, with positioning accuracy within 10 meters. |
| READ_PHONE_STATE | Collect information on SIM card |
| QUERY_ALL_PACKAGES | Collect installed packages |
Cautions
- Ensure that it is initialized after the user agrees to the privacy agreement.
API Call Example
Initialize the SDK and retrieve device information at the application entry point. During integration, you can call getDeviceInfo at actual business nodes to obtain the device information.
import 'package:trustdevice_pro_plugin/trustdevice_se_plugin.dart';
class _MyAppState extends State<MyApp> {
final _trustdeviceSePlugin = TrustdeviceSePlugin();
@override
void initState() {
super.initState
_initWithOptions();
}
Future<void> _initWithOptions() async {
try {
var options = {
"partner": "demo",
"appKey": "appKey",
"channel": "channel",
"country": "cn",
};
// init plugin
await _trustdeviceSePlugin.initWithOptions(options);
// invoke getDeviceInfo method
final resultData = await _trustdeviceSePlugin.getDeviceInfo();
// get response data
final fpVersion = resultData['fpVersion'] as String? ?? '';
final blackBox = resultData['blackBox'] as String? ?? '';
final anonymousId = resultData['anonymousId'] as String? ?? '';
final deviceRiskScore = resultData['deviceRiskScore'] as int? ?? 0;
final sealedResult = resultData['sealedResult'] as String? ?? '';
final apiStatus = resultData['apiStatus'] as Map<String, dynamic>? ?? {};
final statusCode = apiStatus['code'] as int? ?? -1;
final statusMessage = apiStatus['message'] as String? ?? '';
} on PlatformException catch (e) {
// error response
print("e.code: ${e.code}");
print("e.message: ${e.message}");
} catch (e) {
print(“error: ${e}”);
}
}
}Response Data
A response code of 0 in apiStatus['code'] signifies successful device information acquisition. The getDeviceInfo() function returns response data containing the following fields. The sealedResult field is exclusively provided when Sealed Client Results functionality is activated.
| Field | Desc. |
|---|---|
| anonymousId | Device anonymous ID, device identifier |
| blackBox | Call log query identifier |
| fpVersion | SDK version |
| deviceRiskScore | evice risk score |
| sealedResult | Encrypted device information, Base64 encoded binary string, returned only when Sealed Client Results is enabled |
If getDeviceInfo fails, you can catch PlatformException. The corresponding code and message values are as follows:
| code | message | 备注 |
|---|---|---|
| 0 | Success. | Success |
| 1000 | Invalid parameters. | Invalid parameters passed |
| 1001 | SDK error. | SDK exception occurred. Possible reasons: Initialization function not called |
| 1002 | Network error. | Network error |
| 1003 | API error. | Backend interface returned error |
| 1004 | Traffic limit. | Gateway rate limiting response |
| 1100 | Unknown error | Unknown error |
Additional
Get SDK Version
_trustdeviceSePlugin.getSDKVersion();Obfuscation Packaging
If Android requires obfuscation packaging using ProGuard, add the following code to the ProGuard configuration file:
-keep class com.trustdecision.**{*;}Configuration
key | Desc. | Platform | Sample | Excluded Fields |
|---|---|---|---|---|
partner(Required) | Partner code. Please contact operations to obtain | All | options["partner"] = "Please enter your partner code" | |
appKey(Required) | Application identifier. Refer to Get appKey | All | options["appKey"] = "Please enter your appKey" | |
country(Required) | cn for China,sg for Singapore, | All | options["country"] = "Please enter your country/region" | |
channel | Please contact operations to obtain | All | options["channel"] = "Please enter your channe" | |
debug | Anti-debugging feature. Default: off. Enable during development, disable when releasing | All | options["debug"] = true | |
timeLimit | Network request callback timeout in seconds. Default: 15s | All | options["timeLimit"] = 5 | |
location | Whether to collect location information. Default: enabled | All | options["location"] = true | |
IDFA | Whether to collect advertising identifier. Default: enabled | iOS | options["IDFA"] = true | idfa |
deviceName | Whether to collect device name. Default: enabled | iOS | options["deviceName"] = true | device_name |
runningTasks | Whether to get running tasks. Default: enabled | Android | options["runningTasks"] = true | running_packages |
sensor | Whether to collect sensor information. Default: collected | Android | options["sensor"] = true | mangetic_field_sensor、gyroscope_sensor、light_sensor、accelerator_data、gravity_data |
readPhone | Whether to collect READ_PHONE_STATE permission related information. Default: collected | Android | options["readPhone"] = true | country_iso、carrier、network_operator、sim_operator、phone_type、radio_type、device_svn |
installPackageList | Whether to collect installed package list. Default: collected | Android | options["installPackageList"] = true | installed_packages |
OAID | Whether to collect OAID. Default: collected | Android | options["OAID"] = false | oaid |
AID | Whether to collect AID. Default: collected | Android | options["AID"] = false | aid |
ANDROID_ID | Whether to collect ANDROID_ID. Default: collected | Android | options["ANDROID_ID"] = false | androidid |
customMessage | Custom message. SDK supports passthrough and storage | All | options["customMessage"] = "" |
