# 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: https://www.trustdecision.com/legal/privacy-policy
# Environment
Items | Description |
---|---|
Supported System Versions | iOS9.0+ |
Supporting architecture | armv7, arm64, x86_64 |
# Integrate Steps
# CocoaPods
- Added
pod 'TrustDecisionPro', '4.2.4.2'
in the corresponding target in the Podfile - Added
pod 'TrustDecisionCaptcha', '2.1.8'
in the corresponding target in the Podfile - Execute the
pod install --repo-update
command in the folder where the Podfile is located. (M1 series mac computers need to executearch -x86_64 pod install --repo-update
command)
# SDK Structure
files in Pods/TrustDecisionPro directory:
- TDMobRisk.framework(TrustDecision SDK, is a static library type)
- TDCorePlugin.framework (TrustDecision plugin, is an Embed dynamic library type)
files in Pods/TrustDecisionCaptcha directory:
- libTDCaptcha.a(Mob-Risk SDK captcha component library, is a static library type)
- TDCaptchaResource.bundle (Mob-Risk SDK captcha component Required resource package)
# Import Header File
Please import the header file if you want to call SDK API.
#import <TDMobRisk/TDMobRisk.h>
# Initialization
Precautions
When the installation starts for the first time, the SDK initialization is performed after the user agrees with the privacy agreement.
Avoid SDK initialization collection without the user agreeing to the privacy agreement, causing compliance risk accidents.
# Interface Definition
void (*initWithOptions)(NSDictionary *options);
Sample Code
- (void)initTrustDecisionSDK:(void (^)(NSString *blackbox))callback {
// Get riskManager
TDMobRiskManager_t *riskManager = [TDMobRiskManager sharedManager];
// Initialization Configuration
NSMutableDictionary *options = [NSMutableDictionary dictionary];
/*************************** Mandatory Parameter ***************************/
//Partner code, Refer to `Required Configuration`
[options setValue:@"[Your partner]" forKey:@"partner"];
//App key, Refer to `Required Configuration`
[options setValue:@"[Your appKey]" forKey:@"appKey"];
//App name, Refer to `Required Configuration`
[options setValue:@"[Your appName]" forKey:@"appName"];
//Country code, Refer to `Required Configuration`
[options setValue:@"[Your country code]" forKey:@"country"];
/*************************** Optional Parameter ***************************/
#ifdef DEBUG
// !!! If not set this parameter in DEBUG mode, the app will terminate
[options setValue:@"allowed" forKey:@"allowed"];
#endif
[options setValue:^(NSString *blackbox) {
// The callback here is in the sub thread
// Under normal network conditions, the results will be returned within 200-300ms.
// If the network is abnormal, it will return after the timeout timeLimit (default: 15s).
// Please add your processing logic for blackbox below
if (callback) {
callback(blackbox);
}
} forKey:@"callback"];
riskManager->initWithOptions(options);
}
Required Configuration
Key | Definition | Description | Scene | Sample code |
---|---|---|---|---|
partner | Partner code | Partner, please contact TrustDecision to obtain | All Scenes | Objective C [options setValue:@"[Your partner]" forKey:@"partner"]; Swift options.updateValue("[Your partner]" as NSObject, forKey: "partner") |
appKey | App key | Appkey, please offer your App bundleId for TrustDecision to obtain appkey creation requires the user to provide the application bundleId. ⚠️ Different values for bundleId are used for different applications | All Scenes | Objective C [options setValue:@"[Your appKey]" forKey:@"appKey"]; Swift options.updateValue("[Your appKey]" as NSObject, forKey: "appKey") |
appName | App name | AppName, please contact TrustDecision to obtain | All Scenes | Objective C [options setValue:@"[Your appName]" forKey:@"appName"]; Swift options.updateValue("[Your appName]" as NSObject, forKey: "appName") |
country | Country code | Country/region parameters, such as cn sg us fra | Fill in the corresponding parameters according to country and region of business. cn means China, sg means Singapore, us means North America, fra means Europe | Objective C [options setValue:@"[Your country code]" forKey:@"country"]; Swift options.updateValue("[Your country code]" as NSObject, forKey: "country") |
# Get SDK Version
Sample Code
// Get SDK Version
TDMobRiskManager_t *riskManager = [TDMobRiskManager sharedManager];
NSString *sdkVersion = riskManager->getSDKVersion();
# Captcha
# initWithOptions Optional Parameters
Key | Definition | Description | Scene | Sample code |
---|---|---|---|---|
language | language type | Options: 1-Simplified Chinese, 2-Traditional Chinese, 3-English, 4-Japanese, 5-Korean, 6-Malay, 7-Thai, 8-Indonesian, 9-Russian Default: 1-Simplified Chinese | You can set the language type according to your needs, Chinese mainland support 1-5, overseas support 1-9 | [options setValue:@"1" forKey:@"language"]; |
tapToClose | Click on the blank space to close the Captcha window | Optional: true, false Default: false | After opening, click on the blank area of the interface to close the Captcha window, which is more convenient to close the pop-up window | [options setValue:@(true) forKey:@"tapToClose"]; |
needSeqid | Whether to carry the seqid in the failure callback message | Optional: true, false Default: true | When enabled, the seqid serial number will be carried in the failure message, provide TrustDecision with seqId to facilitate troubleshooting | [options setValue:@(true) forKey:@"needSeqid"]; |
hideLoadHud | Whether to skip the loading animation | Options: true, false Default: false | When enabled, the loading animation will not be displayed when the Captcha window pops up, shortening the verification time | [options setValue 😡(true) forKey:@"hideLoadHud"]; |
hideWebCloseButton | Whether to hide the close button of the webview | Options: true, false Default: false | Scenarios that need to be forced to complete the Captcha | [options setValue:@(true) forKey:@"hideWebCloseButton "]; |
openLog | Whether to open the log | Options: true, false Default: false | When enabled, the console will output more log information during debugging, which is convenient for troubleshooting | [options setValue:@( true) forKey:@"openLog"]; |
skipCaptcha | Whether to skip the TrustDecision Captcha verification | Options: true, false Default: false | When enabled, the Captcha will not be verified, and a 4000 error code will be returned at the same time, which is used for dynamic settings Whether to use TrustDecision Captcha SDK verification | [options setValue:@(true) forKey:@"skipCaptcha"]; |
mfaId | MFA ID | Optional: string Default: nil | If you have connected to the MFA product (the description can be ignored if the MFA is not connected), please set the mfa_id which is obtained from the MFA process to the configuration parameter. | [options setValue:@"mfaId string" forKey:@"mfaId"]; |
# Popup Captcha Window
showCaptcha method
The showCaptcha method is used to display the Captcha window, and its interface is defined as follows
// Display Captcha window
// @param superView The parent view where the popup is displayed, UIView type
// @param block result callback block
void (*showCaptcha)(id superView,TongdunShowCaptchaBlock block);
Callback parameter structure TongdunShowCaptchaResultStruct
We use the TongdunShowCaptchaResultStruct structure to store the result of the callback;
typedef enum {
// The Captcha is verified successfully, and a valid validateToken can be obtained at this time;
TongdunShowCaptchaResultTypeSuccess,
// If the Captcha fails, you can get the error code errorCode and errorMsg, and check the cause according to the `Error code` in the document;
TongdunShowCaptchaResultTypeFailed,
// The Captcha window pop-up is successful, waiting to be verified;
TongdunShowCaptchaResultTypeReady,
} TongdunShowCaptchaResultType;
typedef struct _TongdunShowCaptchaResultStruct{
// return result type
TongdunShowCaptchaResultType resultType;
// After returning successfully, the token of the Captcha returned
const char*validateToken;
// After the return fails, the returned error code can be checked according to the document
NSInteger errorCode;
// Return error message after failure
const char*errorMsg;
}TongdunShowCaptchaResultStruct;
Example Code
- (void)showCaptcha {
UIWindow * keyWindow = [UIApplication sharedApplication].keyWindow;
TDMobRiskManager_t *riskManager = [TDMobRiskManager sharedManager];
riskManager->showCaptcha(keyWindow,^(TongdunShowCaptchaResultStruct resultStruct) {
switch (resultStruct. resultType) {
case TongdunShowCaptchaResultTypeSuccess:
{
NSString * validateToken = resultStruct.validateToken;
NSLog(@"Obtain TrustDecision Captcha successfully!!!,validateToken:%@",validateToken);
}
break;
case TongdunShowCaptchaResultTypeFailed:
{
NSString * errorMsg = resultStruct. errorMsg;
NSLog(@"Get TrustDecision Captcha failed!!!, errorCode:%ld, errorMsg:%@",resultStruct.errorCode,errorMsg);
}
break;
case TongdunShowCaptchaResultTypeReady:
NSLog(@"Captcha window popup is successful, waiting to be verified!!!");
break;
default:
break;
}
});
}
# Error Code
The error code of the captcha function module will be output through [TDMobRiskManager sharedManager]->showCaptcha method
Error code | Error message | Processing method |
---|---|---|
1001 | The Captcha window is closed | After the Captcha window popup, the user manually cancels the Captcha, no processing is required |
2001 | The request parameter is abnormal, please check the parameter | Please check the appName and partnerCode parameters |
2100 | The request parameter is abnormal, please check the parameter | Please check the passed parameter |
2101 | The request parameter is abnormal, please check the parameter | There is an error in the request process, please contact the operator |
2102 | The request parameter is abnormal, please check the parameter | The parameter is missing, please check the parameter |
2111 | Authentication page network error | Try again later, or please contact the operator |
2112 | Verification page operation is too frequent | Try again later |
2113 | Unknown error | Unknown error, please contact the operator |
2114 | Closed the Captcha window | Clicked the Captcha close button, no need to process |
2115 | Authentication page network error | Failed to load network resources |
2116 | Authentication page network error | Failed to load network resources |
2202 | Verification succeeded | The verification result is successful and no processing is required |
2301 | Did not purchase this service | Please contact the operator |
2302 | Traffic has been disabled | Please contact the operator |
2303 | Insufficient traffic | Please contact the operator |
2304 | Service has expired | Please contact the operator |
2305 | Daily traffic has been capped | Please contact the operator |
2600 | The system is busy, please try again later | The system is busy, please try again later |
2601 | Authentication failed, try again later | Authentication failed, please try again later |
2602 | Authentication failed, try again later | Authentication failed, please try again later |
2603 | Authentication failed, try again later | Authentication failed, please try again later |
2604 | Authentication failed, try again later | Refresh frequently, please try again later |
2605 | Verification failed, try again later | Failed to obtain Captcha information |
2702 | Authentication failed, try again later | Parsing error, please try again later |
3001 | SSL certificate verification failed | Please close the network proxy tool |
3002 | Error loading verification page | Refresh the network and try again |
3003 | Authentication page load timed out | Check network and try again |
4000 | Validation logic skipping | Developers manually handle validation skipping logic |
9000 | The device fingerprint is not mounted | To integrate the Captcha, you need to integrate the device fingerprint first |
9001 | No network | Please check network connection |
9002 | Request timed out | Check network, try again later |
9003 | Return result is abnormal | Server error, return result is abnormal, contact technical support |
9004 | Global loading timed out | Check network, try again later |
# FAQ
Q1: After integrated the TrustDecision SDK, the project can no longer be debugged in Xcode. How to solve it?
A1: Please refer to Initialization (opens new window) When initializing TrustDecision SDK, add the following parameters
[options setValue:@"allowed" forKey:@"allowed"];