DeviceDNA iOS 库允许您使用 Judopay Genome 服务识别设备。
CocoaPods 是 Cocoa 项目的依赖项管理器。
$ gem install cocoapods
Podfile
文件,将其集成到您的 Xcode 项目中。source 'https://github.com/CocoaPods/Specs.git'
pod 'DeviceDNA', '~> 2.0'
$ pod install
.xcworkspace
文件**,而不是项目的 .xcodeproj
文件。swift
@import DeviceDNA
obj-c
#import <DeviceDNA/DeviceDNA.h>
swift
let credentials = Credentials(<YOUR_TOKEN> secret:<YOUR_SECRET>)
let deviceDNA = DeviceDNA(credentials: credentials)
obj-c
Credentials *credentials = [[Credentials alloc] initWithToken:<YOUR_TOKEN> secret:<YOUR_SECRET>];
DeviceDNA *deviceDNA = [[DeviceDNA alloc] initWithCredentials:credentials];
swift
deviceDNA.identifyDevice { (deviceIdentifier, error) in
//Your provided callback.
}
obj-c
[deviceDNA identifyDevice:^(NSString * _Nullable deviceIdentifier, NSError * _Nullable error) {
//Your provided callback.
}];
swift
deviceDNA.getDeviceProfile(deviceId) { (device, error) in
//Your provided callback.
}
obj-c
[deviceDNA getDeviceProfile:deviceId completion:^(NSDictionary<NSString *,id> * _Nullable device, NSError * _Nullable error) {
//Your provided callback.
}];
当使用 Judopay API 执行服务器端支付时,您可能希望在支付时识别设备。 要获取欺诈预防所需的设备信号,请使用 DeviceDNA 获取加密的信号,这些信号将传递到请求正文的 clientDetails
JSON 字段中。
swift
deviceDNA.getDeviceSignals { (device, error) in
if let device = device as [String : String]?
let deviceId = device["deviceIdentifier"];
let key = device["key"];
let value = device["value"];
}
}
obj-c
[deviceDNA getDeviceSignals:^(NSDictionary<NSString *,NSString *> * _Nullable device, NSError * _Nullable error) {
NSString *deviceId = device["deviceIdentifier"];
NSString *key = device["key"];
NSString *value = device["value"];
}];