API Reference
中文

iOS

Requirement

Environment

ItemsDescription
Supported System VersionsiOS 9.0 and above
Supported Architecturesarmv7, 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 execute arch -x86_64 pod install --repo-updatecommand)

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 after initWithOptions

Definition

void (*getDeviceInfo)(TDDeviceInfoCallback callback);

Best Practices

  1. 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)
}
  1. 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

  1. 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.

KeyDescription
anonymousIdDevice anonymous ID, device identification
blackBoxCall log query identifier
fpVersionSDK Version
deviceRiskScoreCurrent device risk score
sealedResultEncrypted 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
[options setValue:@"your partner" forKey:@"partner"];
Swift
options.updateValue("your partner" , forKey: "partner")

appKey(required)

Application identification, please refer tohow to get appKey

Objective C
[options setValue:@"your appKey" forKey:@"appKey"];
Swift
options.updateValue("your appKey" , forKey: "appKey")

country(required)

Data-center: cn for China fra for Europe sg for Singapore idna for Indonesia us for the USA

Objective C
[options setValue:@"cn" forKey:@"country"];
Swift
options.updateValue("cn" , forKey: "country")

channel

Channel, contact operator to obtain

Objective C
[options setValue:@"your channel" forKey:@"channel"];
Swift
options.updateValue("your channel", forKey: "channel")

timeLimit

Network timeout configuration, in seconds, default 15s

Objective C
[options setValue:@(5) forKey:@"timeLimit"];
Swift
options.updateValue(5, forKey: "timeLimit")

location

Whether collecting GPS location information, default allowed

Objective C
[options setValue:@(YES) forKey:@"location"];
Swift
options.updateValue(true, forKey: "location")

latitude、longitude、gps_location

IDFA

Whether collecting IDFA information, default allowed

Objective C
[options setValue:@(YES) forKey:@"IDFA"];
Swift
options.updateValue(true, forKey: "IDFA")

idfa

IDFV

Whether collecting IDFV information, default allowed

Objective C
[options setValue:@(YES) forKey:@"IDFV"];
Swift
options.updateValue(true, forKey: "IDFV")

idfv

wifiIp

Whether collecting wifiIp information, default allowed

Objective C
[options setValue:@(NO) forKey:@"wifiIp"];
Swift
options.updateValue(false, forKey: "wifiIp")

wifiIp

cellIp

Whether collecting cellIp information, default allowed

Objective C
[options setValue:@(NO) forKey:@"cellIp"];
Swift
options.updateValue(false, forKey: "cellIp")

cellIp

vpnIp

Whether collecting vpnIp information, default allowed

Objective C
[options setValue:@(NO) forKey:@"vpnIp"];
Swift
options.updateValue(false, forKey: "vpnIp")

vpnIp

wifiIpv6

Whether collecting wifiIpv6 information, default allowed

Objective C
[options setValue:@(NO) forKey:@"wifiIpv6"];
Swift
options.updateValue(false, forKey: "wifiIpv6")

wifiIpv6

deviceName

Whether collecting device name information, default allowed

Objective C
[options setValue:@(NO) forKey:@"deviceName"];
Swift
options.updateValue(false, forKey: "deviceName")

device_name

ssid

Whether collecting ssid information, default allowed

Objective C
[options setValue:@(NO) forKey:@"ssid"];
Swift
options.updateValue(false, forKey: "ssid")

ssid

customMessage

Custom messages, SDK supports transparent transmission and storage

Objective C
[options setValue:@"this is a customMessage" forKey:@"customMessage"];
Swift
options.updateValue("this is a customMessage", forKey: "customMessage")

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:

CodeMessageRemarks
0Success.Success
1000Invalid parameters.The parameter passed in is invalid
1001SDK error.SDK exception occurs, possible reasons:Initialization function not called
1002Network error.Network Error
1003API error.The server returns an error
1004Traffic limit.Gateway current limiting return