Risk SDK for iOS
Overview
For client apps, we recommend integrating the native SDK from our risk service providers (Checkout & Forter). This ensures the collection of high-quality device data in complex app environments, improving the accuracy of risk detection. Native integration eliminates the latency and complexity introduced by intermediate forwarding, enhancing the overall payment experience while meeting strict requirements for data reliability, independence, and compliance. This offers merchants a safer, more efficient risk management solution.
Integration steps
1.Add OSLPayRiskSDK.xcframework
- Drag the OSLPayRiskSDK.xcframework file into your Xcode project (it is recommended to place it in the Frameworks folder).
- In the dialog that appears, check Copy items if needed, and select all targets for the project.
2.Configure Frameworks, Libraries, and Embedded Content
- Open your project’s TARGETSsection, locate Frameworks, Libraries, and Embedded Contentand set theOSLPayRiskSDKEmbed option to Embed & Sign。
3.Configure dependencies
OSLPayRiskSDK relies on the following third-party libraries. Ensure that these dependencies are included in your main project's Podfile:
pod 'Alamofire', '5.10.2'
pod 'Risk', '3.0.4'
pod 'ForterSDK', :git => 'https://bitbucket.org/forter-mobile/forter-ios-sdk.git', :tag => '3.0.4'
pod 'Alamofire', '5.10.2'
pod 'DeviceKit', '5.7.0'
pod 'FingerprintJS', '1.6.0'
pod 'SwiftyRSA', '1.7.0'
pod 'MMKV', '1.2.11'
pod 'RxSwift', '6.5.0'
pod 'SwiftyJSON', '5.0.2'
pod 'DeviceKit', '5.7.0'Add the following to the bottom of your Podfile:
post_install do |installer|
installer.generated_projects.each do |project|
project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '14.0'
config.build_settings['BUILD_LIBRARY_FOR_DISTRIBUTION'] = true
end
end
end
endExecute the following command to install the dependencies:
pod install
Usage instructions
1.Import the header file In the files where you need to use the SDK, import the following header file:
import OSLPayRiskSDK2.Initialize the SDK Before using the SDK, initialization is required:
// Default production environment
OSLPayRiskSDK.setup()
// Enable sandbox mode for debugging; disable sandbox mode when going live
OSLPayRiskSDK.setup(openSandBoxEnv: true)3.Risk data reporting
@objc public static func collect(complete: ((String) -> Void)? = nil,
onError: (((any Error)?) -> Void)? = nil)
OSLPayRiskSDK.collect { clientInfoToken in
// Reporting succeeded, retrieve clientInfoToken
} onError: { err in
// Reporting failed
}4.Collect device information The collect method automatically gathers the following device information:
| Field Name | Type | Description | Data Source |
|---|---|---|---|
| terminalType | string | Device type; "3" represents iOS | Built-in SDK |
| deviceId | string | Unique device fingerprint | FingerprintJS SDK |
| deviceSessionId | string | Checkout device session ID | Checkout Risk SDK |
| forterMobileUID | string | Forter device identifier | Forter SDK |
| userAgent | string | User agent information | Built-in SDK |
| browserWidth | string | Screen width | UIScreen.main.bounds.width |
| browserHeight | string | Screen height | UIScreen.main.bounds.height |
| lan | string | Device language (e.g., zh-CN) | Built-in SDK |
| browserTimezone | string | Device timezone (e.g., Asia/Shanghai) | NSTimeZone.system.identifier |
| agentOS | string | Operating system | UIDevice.current.systemName |
| appVersion | string | App version | Bundle.main.infoDictionary["CFBundleShortVersionString"] |
| appname | string | App name | Bundle.main.infoDictionary["CFBundleDisplayName"] |
| osVersion | string | Operating system version | UIDevice.current.systemVersion |
| brand | string | Device brand | Apple |
| model | string | Device model | UIDevice.current.model |
Reference files
Updated 8 days ago