iOS

Requirement

Compliance

Please note that when integrating SDK products provided by 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 Policy: https://www.trustdecision.com/legal/privacy-policy

Environment

ItemsDescription
Supported System VersionsiOS 9.0 and above
Supported Architecturesarmv7, arm64, x86_64

Integrate

integrate sample : https://github.com/trustdecision/mobrisk-ios-sample

Install

If installing offline, please refer to Offline Install

Structure

  • TDMobRisk.framework(TrustDecision SDK, is a static library)
  • TDCorePlugin.framework (TrustDecision plugin, is an Embed dynamic library)
  • FMDeviceManagerFramework.a (DeviceFingerprint SDK, is a static library)

Install(CocoaPods)

  • Add pod 'TrustDecisionPro', '4.2.6.4' 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-update command)

Import Header File

#import <TDMobRisk/TDMobRisk.h>
import TDMobRisk

App Privacy Configuration

According to the latest App Store Privacy Policy announced by Apple, starting from the spring of 2024, apps listed on the App Store will need to carry an App privacy list document.
Starting May 1, 2024, App Store Connect will not accept apps that do not describe their use of the required reason API in a privacy manifest file.

Adaptation Steps

Please choose a solution based on your actual situation.

  1. If the PrivacyInfo.xcprivacy file does not exist in the project directory
  • Create a new App Privacy type file through Xcode in the project directory, name it PrivacyInfo, and check the required Targets
  • Select the PrivacyInfo.xcprivacy file in the project directory and right-click to open the menu. Open the file through Open As -> Source Code in the menu
  • Paste the SDK's PrivacyInfo.xcprivacy below into the PrivacyInfo.xcprivacy file in the project directory
  1. If the PrivacyInfo.xcprivacy file already exists in the project directory
  • Select the PrivacyInfo.xcprivacy file in the project directory and right-click to open the menu. Open the file through Open As -> Source Code in the menu.
  • Added content in the PrivacyInfo.xcprivacy file in the project directory that is mentioned in SDK's PrivacyInfo.xcprivacy but is still missing in the project directory PrivacyInfo.xcprivacy file

SDK's PrivacyInfo.xcprivacy

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>NSPrivacyCollectedDataTypes</key>
	<array>
		<dict>
			<key>NSPrivacyCollectedDataType</key>
			<string>NSPrivacyCollectedDataTypeDeviceID</string>
			<key>NSPrivacyCollectedDataTypeLinked</key>
			<true/>
			<key>NSPrivacyCollectedDataTypeTracking</key>
			<false/>
			<key>NSPrivacyCollectedDataTypePurposes</key>
			<array>
				<string>NSPrivacyCollectedDataTypePurposeAnalytics</string>
				<string>NSPrivacyCollectedDataTypePurposeAppFunctionality</string>
			</array>
		</dict>
	</array>
	<key>NSPrivacyAccessedAPITypes</key>
	<array>
		<dict>
			<key>NSPrivacyAccessedAPIType</key>
			<string>NSPrivacyAccessedAPICategoryDiskSpace</string>
			<key>NSPrivacyAccessedAPITypeReasons</key>
			<array>
				<string>E174.1</string>
			</array>
		</dict>
		<dict>
			<key>NSPrivacyAccessedAPIType</key>
			<string>NSPrivacyAccessedAPICategoryUserDefaults</string>
			<key>NSPrivacyAccessedAPITypeReasons</key>
			<array>
				<string>CA92.1</string>
			</array>
		</dict>
		<dict>
			<key>NSPrivacyAccessedAPIType</key>
			<string>NSPrivacyAccessedAPICategorySystemBootTime</string>
			<key>NSPrivacyAccessedAPITypeReasons</key>
			<array>
				<string>35F9.1</string>
			</array>
		</dict>
	</array>
</dict>
</plist>

Initialization

Cautions

  • Ensure that it is initialized after the user agrees to the privacy agreement.

Definition

void (*initWithOptions)(NSDictionary *options);

Get blackBox

Cautions

  • Call getBlackBox or getBlackBoxAsync after initWithOptions.
  • Don't cache blackBox returned by getBlackBox in the app. Please rely on this function to get blackBox.

Definition

   /* Get blackBox asynchronously */
   void (*getBlackBoxAsync)(TDGetBlackBoxAsyncBlock block);
   /* Get blackBox synchronously */
   NSString (*getBlackBox)(void);

Best Practices

  1. Call initialization at entry of the application, and obtain blackBox asynchronously
- (void)initTrustDecisionSDK {
  // Get riskManager
  TDMobRiskManager_t *riskManager = [TDMobRiskManager sharedManager];
  // Initialization Configuration
  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"];

/*************************** Optional  ***************************/
#ifdef DEBUG
  // !!! If not set this parameter in DEBUG mode, the app will terminate
  [options setValue:@(YES) forKey:@"allowed"];
  // Listen for error codes
  riskManager->setOnErrorCodeListener(^(int errorCode,const char* errorMsg){
       NSLog(@":errorCode:%d,errorMsg:%s",errorCode,errorMsg);
   });

#endif
  riskManager->initWithOptions(options);
}
func initTrustDecisionSDK() {
  let riskManager = TDMobRiskManager.sharedManager()
  var options = Dictionary<String, Any>()
  /*************************** Mandatory Parameter ***************************/
  // Partner code, Refer to `Required Configuration`
  options.updateValue("[Your partner]" , forKey: "partner")
  // App key, Refer to `Required Configuration`
  options.updateValue("[Your appKey]" , forKey: "appKey")
  // Country code, Refer to `Required Configuration`
  options.updateValue("[Your country]" , forKey: "country")

   /*************************** Optional Parameter ***************************/
#if DEBUG
  // !!! If not set this parameter in DEBUG mode, the app will terminate
  options.updateValue(true, forKey: "allowed")

  // Listen for error codes
  riskManager?.pointee.setOnErrorCodeListener(){(errorCode : Int32!,errorMsg : UnsafePointer<CChar>!)->Void in
      print("errorCode: \(errorCode), errorMsg: \(String(validatingUTF8: errorMsg))")
  };
#endif
  // !!!The callback method has been removed, and now a getBlackBoxAsync method has been added to asynchronously obtain blackBox
 riskManager?.pointee.initWithOptions(options)
 riskManager?.pointee.getBlackBoxAsync(){(blackBoxString : String!)->Void in
 			print("blackBox:" + blackBoxString)                               
    }
}
  1. Obtain blackBox in actual business scenarios
   TDMobRiskManager_t *riskManager = [TDMobRiskManager sharedManager];
   NSString *blackBox = riskManager->getBlackBox();
  let riskManager = TDMobRiskManager.sharedManager()
  let blackBox = riskManager?.pointee.getBlackBox()

Status Check

  1. getBlackBox() will return a 26-bit string while initialization successfully, like rGPGX1678775227I9NCwcuVJCb.
  2. getBlackBox() will return a string of around 5000 bits while initialization Failed, please refer to overview-definition

Other

Get SDK Version

TDMobRiskManager_t *riskManager = [TDMobRiskManager sharedManager];
NSString *sdkVersion = riskManager->getSDKVersion();
let riskManager = TDMobRiskManager.sharedManager()
let sdkVersion = riskManager?.pointee.getSDKVersion()

Error Listen

Please call setOnErrorCodeListener before the initWithOptions method to listen for error messages. It is recommended to use it only in debug mode.

     TDMobRiskManager_t *riskManager = [TDMobRiskManager sharedManager];
     riskManager->setOnErrorCodeListener(^(int errorCode,const char* errorMsg){
         NSLog(@":errorCode:%d,errorMsg:%s",errorCode,errorMsg);
     });
     let riskManager = TDMobRiskManager.sharedManager()
     riskManager?.pointee.setOnErrorCodeListener(){(errorCode : Int32,errorMsg : UnsafePointer<CChar>?)->Void in
          print("errorCode:" + errorCode + "," + "errorMsg:" + errorMsg);
     }

All Configurations

KeyDescriptionSample
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 appKeyObjective 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

inda for Indonesia

us for the USA
Objective C
[options setValue:@"cn" forKey:@"country"];
Swift
options.updateValue("cn" , forKey: "country")
allowedAllow debugging, default false, must be closed before the application release.Objective C
[options setValue:@(YES) forKey:@"allowed"];
Swift
options.updateValue(true, forKey: "allowed")
appNameApplication name, contact operator to obtainObjective C
[options setValue:@"your appName" forKey:@"appName"];
Swift
options.updateValue("your appName", forKey: "appName")
timeLimitNetwork timeout configuration, in seconds, default 15sObjective C
[options setValue:@(5) forKey:@"timeLimit"];
Swift
options.updateValue(5, forKey: "timeLimit")
locationWhether collecting GPS location information, default allowedObjective C
[options setValue:@(YES) forKey:@"location"];
Swift
options.updateValue(true, forKey: "location")
IDFAWhether collecting IDFA information, default allowedObjective C
[options setValue:@(YES) forKey:@"IDFA"];
Swift
options.updateValue(true, forKey: "IDFA")
deviceNameWhether collecting device name, default allowedObjective C
[options setValue:@(YES) forKey:@"deviceName"];
Swift
options.updateValue(true, forKey: "deviceName")
USE_DEMOTIONWhen unable to obtain a normal blackBox, should downgrading be prioritized and disabled by defaultObjective C
[options setValue:@(YES) forKey:@"USE_DEMOTION"];
Swift
options.updateValue(true, forKey: "USE_DEMOTION")
collectLevelYou can set M to control the maximum length of blackBox to 2000, default around 5000Objective C
[options setValue:@"M" forKey:@"collectLevel"];
Swift
options.updateValue("M", forKey: "collectLevel")
customMessageCustom messages, SDK supports transparent transmission and storageObjective C
[options setValue:@"this is a customMessage" forKey:@"customMessage"];
Swift
options.updateValue("this is a customMessage", forKey: "customMessage")

Error Code

codehow to handle
100Ensure initWithOptions is called before getBlackBox or getBlackBoxAsync
101Not affect usage. If you want to obtain a shorter blackBox, you can learn from the best practices mentioned above
102Not affect usage. If you want to obtain a shorter blackBox, try to use getBlackBox() after a successful callback of getBlackBoxAsync
200Required parameter exception, adjust according to the error message
201Please get in touch with our operator to update the validity period of the appKey
202Set the allowed parameter to YES while debugging
300Please first check if the timeLimit configuration has set a too short time. If it still cannot be resolved, please provide the blackBox, code, and error message to the technical for assistance
301Please check the network status of the current device and App first
302Please first check if the appKey and partnerCode meet the document requirements. Then check if the appKey fits the bundleID. If it still cannot be resolved, please provide the blackBox, code, and error message to the technical for assistance
-1Please provide the blackBox, code, and error message to the technical for assistance