Requirement
Environment
Items | Description |
---|---|
Supported System Versions | iOS 9.0 and above |
Supported Architectures | armv7, arm64, x86_64 |
Integrate
Install(CocoaPods)
- Add
pod 'TrustDecisionPro', '5.1.1'
to the target in the Podfile - Execute the
pod install --repo-update
command in the folder where the Podfile is located. (M series mac computers need to executearch -x86_64 pod install --repo-update
command)
Initialization
Cautions
- Ensure that it is initialized after the user agrees to the privacy agreement.
Import Header File
#import <TDMobRisk/TDMobRisk.h>
import TDMobRisk
Definition
void (*initWithOptions)(NSDictionary *options);
Get device information
Cautions
- Call
getDeviceInfo
afterinitWithOptions
Definition
void (*getDeviceInfo)(TDDeviceInfoCallback callback);
Best Practices
- Call initialization at entry of the application
- (void)initDeviceManagerSDK {
TDDeviceManager_t *manager = [TDDeviceManager sharedManager];
NSMutableDictionary *options = [NSMutableDictionary dictionary];
/*************************** Required ***************************/
// get from our customer platform
[options setValue:@"[Your partner]" forKey:@"partner"];
// get from our customer platform
[options setValue:@"[Your appKey]" forKey:@"appKey"];
//Country code, Refer to All configuration
[options setValue:@"[Your country code]" forKey:@"country"];
manager->initWithOptions(options);
}
func initDeviceManagerSDK() {
let manager = TDDeviceManager.sharedManager()
var options = Dictionary<String, Any>()
/*************************** Required ***************************/
// get from our customer platform
options.updateValue("[Your partner]", forKey: "partner")
// get from our customer platform
options.updateValue("[Your appKey]", forKey: "appKey")
// Country code, Refer to All configuration
options.updateValue("[Your country code]", forKey: "country")
manager.pointee.initWithOptions(options)
}
- Obtain device information at the actual business node
TDDeviceManager_t *manager = [TDDeviceManager sharedManager];
manager->getDeviceInfo(^(TDDeviceResponse response){
int code = response.apiStatus.code;
// Char type strings must be converted to String type in multi-threaded situations, otherwise they will be released during thread switching
if(code == 0) {// success
NSString* fpVersion = [[NSString alloc] initWithCString:response.fpVersion ?: "" encoding:NSUTF8StringEncoding];
NSString* blackBox = [[NSString alloc] initWithCString:response.blackBox ?: "" encoding:NSUTF8StringEncoding];
NSString* anonymousId = [[NSString alloc] initWithCString:response.anonymousId ?: "" encoding:NSUTF8StringEncoding];
NSString* message = [[NSString alloc] initWithCString:response.apiStatus.message ?: "" encoding:NSUTF8StringEncoding];
NSString* sealedResult = [[NSString alloc] initWithCString:response.sealedResult ?: "" encoding:NSUTF8StringEncoding];
int deviceRiskScore = response.deviceRiskScore;
}
else{// fail
NSString* message = [[NSString alloc] initWithCString:response.apiStatus.message ?: "" encoding:NSUTF8StringEncoding];
}
});
let manager = TDDeviceManager.sharedManager()
manager.pointee.getDeviceInfo() { (response: TDDeviceResponse!)->Void in
let code = response.apiStatus.code
// Char type strings must be converted to String type in multi-threaded situations, otherwise they will be released during thread switching
if code == 0 {// success
let fpVersion = String(validatingCString: response.fpVersion)
let blackBox = String(validatingCString: response.blackBox)
let anonymousId = String(validatingCString: response.anonymousId)
let message = String(validatingCString: response.apiStatus.message)
let sealedResult = String(validatingCString: response.sealedResult)
let deviceRiskScore = response.deviceRiskScore
}
else {// fail
let message = response.apiStatus.message
}
}
Status Check
- When the code of getDeviceInfo() callback == 0, it means that the device information is obtained successfully;
Response results
The getDeviceInfo() function returns the response data in callback , which contains the following information. sealedResult is returned only when client-side sealed results are enabled.
Key | Description |
---|---|
anonymousId | Device anonymous ID, device identification |
blackBox | Call log query identifier |
fpVersion | SDK Version |
deviceRiskScore | Current device risk score |
sealedResult | Encrypted device information, binary Base64 encoded string, returned only when the client seal result is turned on. The decrypted result is consistent with the information obtained by device information query. For reference: Device call log |
Other
Get SDK Version
TDDeviceManager_t *manager = [TDDeviceManager sharedManager];
NSString* sdkVersion = manager->getSDKVersion();
let manager = TDDeviceManager.sharedManager()
let sdkVersion = manager.pointee.getSDKVersion()
All Configurations
Key | Description | Sample | Remove Field |
---|---|---|---|
partner(required) | Partner code, contact operator to obtain | Objective C | |
appKey(required) | Application identification, please refer tohow to get appKey | Objective C | |
country(required) | Data-center: cn for China fra for Europe sg for Singapore idna for Indonesia us for the USA | Objective C | |
channel | Channel, contact operator to obtain | Objective C | |
timeLimit | Network timeout configuration, in seconds, default 15s | Objective C | |
location | Whether collecting GPS location information, default allowed | Objective C | latitude、longitude、gps_location |
IDFA | Whether collecting IDFA information, default allowed | Objective C | idfa |
IDFV | Whether collecting IDFV information, default allowed | Objective C | idfv |
wifiIp | Whether collecting wifiIp information, default allowed | Objective C | wifiIp |
cellIp | Whether collecting cellIp information, default allowed | Objective C | cellIp |
vpnIp | Whether collecting vpnIp information, default allowed | Objective C | vpnIp |
wifiIpv6 | Whether collecting wifiIpv6 information, default allowed | Objective C | wifiIpv6 |
deviceName | Whether collecting device name information, default allowed | Objective C | device_name |
ssid | Whether collecting ssid information, default allowed | Objective C | ssid |
customMessage | Custom messages, SDK supports transparent transmission and storage | Objective C |
Status code description
Call the TDDeviceManager getDeviceInfo() method. The parameter of type TDDeviceAPIStatus in the callback stores the status information of the SDK. Its definition is as follows:
typedef struct TDDeviceAPIStatus_Void {
/// code
int code;
/// message
NSString *message;
} TDDeviceAPIStatus;
The corresponding values of code and message are as follows:
Code | Message | Remarks |
---|---|---|
0 | Success. | Success |
1000 | Invalid parameters. | The parameter passed in is invalid |
1001 | SDK error. | SDK exception occurs, possible reasons:Initialization function not called |
1002 | Network error. | Network Error |
1003 | API error. | The server returns an error |
1004 | Traffic limit. | Gateway current limiting return |