123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- //
- // XYAPIRiskControManager.m
- // Timi
- //
- // Created by 翟玉磊 on 2021/8/25.
- //
- #import "XYAPIRiskControManager.h"
- #import "SmAntiFraud.h"
- static NSString * const RISK_CONTROL_ACTIVATION_FLAG = @"RISK_CONTROL_ACTIVATION_FLAG";
- @implementation XYAPIRiskControManager
- + (void)initSdkWithOrganization:(NSString *)Organization appId:(NSString *)appId publicKey:(NSString *)publicKey {
- SmOption *option = [[SmOption alloc] init];
- // 1.通用配置项
- [option setOrganization:Organization]; //必填,组织标识,邮件中 organization 项
- [option setAppId:appId]; //必填,应用标识,登录数美后台应用管理查看,没有合适值,可以写 default
- [option setPublicKey:publicKey]; //SDK 版本高于 2.5.0 时必填,加密 KEY,邮件中 ios_public_key 附件内容
- // 2 连接机房特殊配置项
- // 2.1 业务机房在国内
- // 1) 用户分布:中国(默认设置)
- // [option setArea:AREA_BJ];
- // 2) 用户分布:全球
- // [option setArea:AREA_BJ];
- // NSString* host = @"http://fp-it-acc.fengkongcloud.com";
- // [option setUrl:[host stringByAppendingString:@"/deviceprofile/v4"]];
- // [option setConfUrl:[host stringByAppendingString:@"/v3/cloudconf"]];
- // 2.2 业务机房在欧美
- // 1) 用户分布:欧美
- // [option setArea:AREA_FJNY];
- // 2) 用户分布:全球
- // [option setArea:AREA_FJNY];
- // NSString* host = @"http://fp-na-it-acc.fengkongcloud.com";
- // option setUrl:[host stringByAppendingString:@"/deviceprofile/v4"]];
- // option setConfUrl:[host stringByAppendingString:@"/v3/cloudconf"]];
- // 2.3 业务机房在东南亚
- // 1) 用户分布:东南亚
- // [option setArea:AREA_XJP];
- // 2) 用户分布:全球
- // [option setArea:AREA_XJP];
- // NSString* host = @"http://fp-sa-it-acc.fengkongcloud.com";
- // option setUrl:[host stringByAppendingString:@"/deviceprofile/v4"]];
- // option setConfUrl:[host stringByAppendingString:@"/v3/cloudconf"]]; //
- // 2.4 私有化特殊配置
- // 设置私有地址
- // NSString *host = @"http://private-host"; // 将 private-host 替换为您自己的主机名(域名)
- // [option setUrl: [host stringByAppendingString:@"/deviceprofile/v4"]];
- // [option setConfUrl:[host stringByAppendingString:@"/v3/cloudconf"]];
-
- // 3.SDK 初始化
- [[SmAntiFraud shareInstance] create:option];
- // 4.获取设备标识,注意获取到的是,这个接口在需要使用 deviceId 时地方调用
- // 会有极少情况出现 boxData 的情况,boxData 为加密后的采集数据,长度大约 5KB
- // NSString *deviceId = [[SmAntiFraud shareInstance] getDeviceId];
-
- BOOL flag = [[NSUserDefaults standardUserDefaults] boolForKey:RISK_CONTROL_ACTIVATION_FLAG];
- if (!flag) {
- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
- // 反欺诈激活
- [[XYUserAPIManager new] appActivationsuccessHandler:^(ZYLResponseModel *responseModel) {
- [[NSUserDefaults standardUserDefaults] setBool:YES forKey:RISK_CONTROL_ACTIVATION_FLAG];
- } failureHandler:^(ZYLNetworkError *error) {
- }];
- });
- }
- }
- + (NSString *)getRiskControlDeviceId {
- NSString* deviceId = [[SmAntiFraud shareInstance] getDeviceId];
- if (deviceId.length > 0) {
- return deviceId;
- }
- return @"";
- }
- @end
|