一、概述:
1、环境需求
条目 |
资源 |
开发目标 |
iOS8+ |
开发环境 |
Xcode11+ |
系统依赖 |
libc++.1.tbd |
包增量 |
1.3M |
网络制式 |
移动 2G/3G/4G 联通 3G/4G 电信 4G (2G/3G
网络时延迟相对较高,成功率将受到影响) |
网络环境 |
数据网络、数据网络+WIFI |
2、相关开发资料
条目 |
资源 |
产品结构流程 |
通讯流程 |
常见问题 |
见文章底部FAQ |
SDK 当前版本 |
2.3.2 |
3、业务流程
您需要在APP中集成SDK,并在服务端完成API对接。全流程主要分为四个步骤:
第一步,初始化;
第二步,预取号;
第三步,拉取授权页;
第四步,一键登录授权;
第五步,服务端API置换号码(如下图);
4、前置条件
5、SDK 包说明
供下载的 SAI_iOS SDK 压缩包,包含以下几部分:
OXSaiSDK demo 工程
OXSaiSDK.framework(真机)
OXSaiSDK.framework(真机+模拟器)
OXSaiSDK.bundle(资源包)
二、准备工作
1、应用创建
前往官网创建应用获取 APPID 、 APPSECRET
(具体流程请联系客服)
2、开发环境搭建
2.1、SDK 集成
添加 SDK 到工程中
添加相应的 Frameworks ,需要为项目添加的
Frameworks 如下
OXSaiSDK.framework
添加资源包
OXSaiSDK.bundle
添加系统依赖
libc++.1.tbd
2.2、工程配置
- 针对静态库中的 Category , 需要在对应
target 的 Build Settings
-> Other Linker Flags 添加
-ObjC 编译选项 。
- 目前运营商个别接口为 http 请求,需要设置 http 传输。
右键打开工程 plist 文件,加入以下代码
| <key>NSAppTransportSecurity</key> |
| <dict> |
| <key>NSAllowsArbitraryLoads</key> |
| <true/> |
| </dict> |
三、接入说明
1、SDK 初始化
1.1、使用场景
1.2、方法原型
| |
| *SDK 初始化 |
| *@param params 请求参数 |
| *key: app_id value:后台申请的 appId |
| *key: app_secret value:后台申请的 appSecret |
| *@param delegate 代理 |
| */ |
| + (void)initWithParams:(NSDictionary *)params |
| delegate:(id<OXActionDelegate>)delegate; |
1.3、接口作用
初始化 SDK 获取运营商相关配置信息
1.4、请求参数
参数 |
字段 |
类型 |
必填 |
描述 |
params |
app_id |
NSString |
是 |
平台申请的 appid |
app_secret |
NSString |
是 |
平台申请的 appSecret |
timeout |
NSString |
否 |
接口超时时间(单位:秒) |
delegate |
OXActionDelegate |
id |
是 |
代理对象 |
1.5、接口示例
| NSMutableDictionary *params = [[NSMutableDictionary alloc] init]; |
| params[@"app_secret"] = @"52BB77D02D******A0E141B82EED9"; |
| params[@"app_id"] = @"17BC76520B598******1898424ED21E5"; |
| [OXClientEntry initWithParams: params delegate:self]; |
1.6、回调参数
成功
参数 |
类型 |
描述 |
action_type |
NSString |
请求类型 |
request_params |
NSDictionary |
请求参数 |
result |
code |
NSString |
返回码 |
risk_code |
NSString |
风险码(可能存在多个),通过账户进行配置才有返回 (v2.3.2 以上版本) |
risk_level |
NSString |
风险等级 (v2.3.2 以上版本) |
失败
参数 |
类型 |
描述 |
action_type |
NSString |
请求类型 |
request_params |
NSDictionary |
请求参数 |
result |
code |
NSString |
返回码 |
1.7、回调示例
| { |
| "action_type" = 1 |
| "request_params" = { |
| timeout = 3 |
| } |
| result = { |
| "code" = "00000" |
| "request_id" = 15936533936008856 |
| "risk_code" = "2012,2014" |
| "risk_level" = 7 |
| } |
| } |
回调方法
| - (void)oxActionInitSdkResponse:(NSDictionary *)response{ |
| NSString *code = [response[@"result"] valueForKey:@"code"]; |
| if ([code isEqualToString:@"00000"]) { |
| [[OXHUD sharedHUD]showMessage:@"初始化成功"]; |
| }else{ |
| [[OXHUD sharedHUD]showMessage:[NSString stringWithFormat:@"初始化失败 code:%@",code ]]; |
| }} |
1.8、注意事项
建议在 AppDelegate 中初始化 SDK
必须在一键登录前调用只需调用一次,多次调用不会多次初始化,与一次调用效果一致
2、预取号
2.1、使用场景
-
建议在执行一键登录的方法前,提前一段时间调用此方法,比如调一键登录的 vc 的 viewdidload 中,或者 rootVC 的 viewdidload 中,或者
app 启动后,此调用将有助于提高拉起授权页的速度和成功率
-
不建议调用后立即调用拉起授权页方法(此方法是异步)
-
此方法需要 1~2s 的时间取得临时凭证,因此也不建议和拉起授权页方法一起串行调用
-
不建议频繁的多次调用和在拉起授权页后调用
-
建议在判断当前用户属于未登录状态时使用,已登录状态用户请不要调用该方法
2.2、方法原型
| |
| *服务接口(预取号、一键登录、本机号码校验、短信验证) |
| *@param type 请求类型 (OXActionTypePreLogin 预取号) |
| *@param params 请求参数 |
| */ |
| + (void)requestAction:(OXActionType)type params:(NSDictionary *)params; |
2.3、接口作用
电信、联通、移动预取号 :初始化成功后,如果当前为电信/联通/移动,将调用预取号,可以提前获知当前用户的手机网络环境是否符合一键登录的使用条件,成功后将得到用于一键登录使用的临时凭证。
2.4、请求参数
参数 |
类型 |
必填 |
说明 |
type |
OXActionType |
是 |
验证类型枚举(OXActionTypePreLogin) |
params |
NSDictionary |
否 |
可传 nil |
2.5、接口示例
| [OXClientEntry requestAction:OXActionTypePreLogin params:nil]; |
2.6、回调参数
成功
参数 |
类型 |
描述 |
action_type |
NSString |
请求类型 |
request_params |
NSDictionary |
请求参数 |
result |
code |
NSString |
返回码 |
msg |
NSString |
描述 |
失败
参数 |
|
类型 |
描述 |
action_type |
NSString |
请求类型 |
request_params |
NSDictionary |
请求参数 |
result |
code |
NSString |
返回码 |
msg |
NSString |
描述 |
2.7、回调示例
| { |
| "action_type" = 9 |
| "request_params" = { |
| timeout = 3 |
| } |
| result = { |
| "code" = "00000" |
| "msg" = "success" |
| } |
| } |
2.8、回调方法
| - (void)onActionResult:(NSDictionary *)result{ |
| if([result [@"action_type"] integerValue]== |
| OXActionTypePreLogin){ |
| |
| } |
| } |
2.9、注意事项
不建议 频繁的多次调用和在拉起授权页后调用
预取号方法回调中处理 UI 操作需手动切换到主线程
3、一键登录
3.1、使用场景
- 用户进行一键登录操作时,调用一键登录方法,如果初始化成功,SDK 将会拉起授权页面,用户授权后,SDK 将返回取号 token 给到应用客户端。
3.2、方法原型
| |
| *服务接口(预取号、一键登录、本机号码校验、短信验证) |
| *@param type 请求类型 (OXActionTypeGetOnekeyLoginToken 一键登录) |
| *@param params 请求参数 |
| */ |
| + (void)requestAction:(OXActionType)type params:(NSDictionary *)params; |
3.3、接口作用
拉起授权页面,用户在授权页面点击一键登录,即可获取 token,拿该 token 即可换取对应的手机号
3.4、请求参数
参数 |
类型 |
必填 |
说明 |
type |
OXActionType |
是 |
验证类型枚举(OXActionTypeGetOnekeyLoginToken) |
params |
NSDictionary |
是 |
{"current_vc":UIViewController,@"timeout":@"5"} |
3.5、接口示例
| [OXClientEntry requestAction:OXActionTypeGetOnekeyLoginToken params:@{"current_vc":UIViewController,@"timeout":@"5"}]; |
3.6、回调参数
成功
参数 |
类型 |
描述 |
action_type |
NSString |
请求类型 |
request_params |
NSDictionary |
请求参数 |
result |
code |
NSString |
返回码 |
access_token |
NSString |
一键登录token,用于服务端置换手机号 |
risk_code |
NSString |
风险码 (v2.3.2 以上版本) |
risk_level |
NSString |
风险等级 (v2.3.2 以上版本) |
失败
参数 |
|
类型 |
描述 |
action_type |
NSString |
请求类型 |
request_params |
NSDictionary |
请求参数 |
result |
code |
NSString |
返回码 |
msg |
NSString |
描述 |
3.7、回调示例
| { |
| "action_type" = 3 |
| "request_params" = { |
| timeout = 5 |
| } |
| result = { |
| "access_token" = "onekey_15936539420434a5xxxxxx4067b0a2e14e900e69fa" |
| "code" = "00000" |
| "risk_code" = "2012,2014" |
| "risk_level" = 7 |
| } |
| } |
3.8、回调方法
| - (void)onActionResult:(NSDictionary *)result{ |
| NSString *code = [response[@"result"] valueForKey:@"code"]; |
| if([result [@"action_type"] integerValue]==OXActionTypeGetOnekeyLoginToken){ |
| if([code isEqualToString:@"45033"]){ |
| NSLog(@"成功调起授权页"); |
| }else{ |
| if ([code isEqualToString:@"00000"]) { |
| [[OXHUD sharedHUD] showMessage:@"获取 token 成功"]; |
| }else if ([code isEqualToString:@"45009"]){ |
| [[OXHUD sharedHUD] showMessage:@"取消登录"]; |
| }else{ |
| [[OXHUD sharedHUD] showMessage:@"登录失败"]; |
| } |
| } |
| } |
| } |
3.9、ACCESS_TOKEN 使用
SDK 成功返回 token 后,开发者需自行调用置换手机号接口,此接口需要开发者调用由服务端接入服务端生成的接口,上线前的调试阶段可以直接使用demo示例代码中的接口
| [[OXNetworkManager sharedRequest] post:KURL parameters:parames success:^(NSDictionary * _Nonnull responseObject) { |
| [[OXHUD sharedHUD]showMessage:[responseObject[@"object"] valueForKey:@"tel"]]; |
| [[OXHUD sharedHUD]showMessage:@"网络异常"]; |
| } failure:^(NSString * _Nonnull code) { |
| [[OXHUD sharedHUD]showMessage:@"置换手机号失败"]; |
| } netFail:^(NSError * _Nonnull error) { |
| [[OXHUD sharedHUD]showMessage:@"网络异常"]; |
| }]; |
具体的请求参数和 URL 请参考 DEMO
3.10、注意事项
必须开启数据网络、初始化完成后调用
4、本机号码校验
4.1、使用场景
- 用户输入手机号码,通过SDK获取token,服务端携带输入的手机号码和token去运营商网关进行校验,返回的结果是用户当前上网使用的号码与输入的号码是否一致。
4.2、方法原型
| |
| *服务接口(预取号、一键登录、本机号码校验、短信验证) |
| *@param type 请求类型 (OXActionTypeGetMobileAuthToken 一键登录) |
| *@param params 请求参数 |
| */ |
| + (void)requestAction:(OXActionType)type params:(NSDictionary *)params; |
4.3、接口作用
获取用于验证的token。(此接口仅返回 token,手机号验证需调用服务端)
4.4、请求参数
参数 |
类型 |
必填 |
说明 |
type |
OXActionType |
是 |
验证类型枚举(OXActionTypeGetMobileAuthToken) |
params |
NSDictionary |
否 |
可传 nil |
4.5、接口示例
| [OXClientEntry requestAction:OXActionTypeGetMobileAuthToken params: nil]; |
4.6、回调参数
成功
参数 |
类型 |
描述 |
action_type |
NSString |
请求类型 |
request_params |
NSDictionary |
请求参数 |
result |
code |
NSString |
返回码 |
access_token |
NSString |
用户本机号码校验 |
risk_code |
NSString |
风险码 (v2.3.2 以上版本) |
risk_level |
NSString |
风险等级 (v2.3.2 以上版本) |
失败
参数 |
类型 |
描述 |
action_type |
NSString |
请求类型 |
request_params |
NSDictionary |
请求参数 |
result |
code |
NSString |
返回码 |
msg |
NSString |
描述 |
4.7、回调示例
| { |
| "action_type" = 7 |
| "request_params" = { |
| timeout = 5 |
| } |
| result = { |
| "access_token" = "onekey_1593684074115247xxxxx9438ca8a5918d0760486e" |
| "code" = "00000" |
| "risk_code" = "2012,2014" |
| "risk_level" = 7 |
| } |
| } |
4.8、回调方法
| - (void)onActionResult:(NSDictionary *)result{ |
| if([result[@"action_type"] integerValue]== OXActionTypeGetMobileAuthToken ){ |
| |
| } |
| } |
4.9、ACCESS_TOKEN 使用
SDK 成功返回 token
后,开发者需自行调用本机号码校验接口,此接口需要开发者调用由服务端接入服务端生成的接口,上线前的调试阶段可以直接使用demo示例代码中的接口
| [[OXNetworkManager sharedRequest] post:KURL parameters:Parames success:^(NSDictionary * _Nonnull responseObject) { |
| if ([[responseObject[@"object"] valueForKey:@"is_local_phone"] isEqualToString:@"0"]) { |
| [[OXHUD sharedHUD]showMessage:@"本机号码"]; |
| }else{ |
| [[OXHUD sharedHUD]showMessage:@"非本机号码"]; |
| } |
| } failure:^(NSString * _Nonnull code) { |
| [[OXHUD sharedHUD]showMessage:@"本机号码获取 token 失败"]; |
| } netFail:^(NSError * _Nonnull error) { |
| [[OXHUD sharedHUD]showMessage:@"网络异常"]; |
| }]; |
具体的请求参数和 URL 请参考 DEMO
4.10、注意事项
必须开启数据网络
5、短信验证
5.1、使用场景
短信验证码身份验证和登录
5.2、方法原型
| |
| *服务接口(预取号、一键登录、本机号码校验、短信验证) |
| *@param type 请求类型 (OXActionTypeVerifyBySmsStart 短信验证开启 |
| OXActionTypeVerifyBySmsCheck 验证码校验) |
| *@param params 请求参数 |
| */ |
| + (void)requestAction:(OXActionType)type params:(NSDictionary *)params; |
5.3、接口作用
获取短信验证码、短信验证码校验
5.4、请求参数
参数 |
类型 |
必填 |
说明 |
type |
OXActionType |
是 |
验证类型枚举(OXActionTypeVerifyBySmsStart、OXActionTypeVerifyBySmsCheck) |
params |
NSDictionary |
是 |
短信开启: {"tel":"手机号码"} 验证码校验:
{"tel":"手机号码","sms_code":"短信验证码"} |
5.5、接口示例
| |
| NSMutableDictionary *params = [[NSMutableDictionary alloc] init]; |
| params[@"tel"] = @"1555***5555"; |
| [OXClientEntry requestAction:OXActionTypeVerifyBySmsStart params: params]; |
| |
| NSMutableDictionary *params = [[NSMutableDictionary alloc] init]; |
| params[@"tel"] = @"1555***5555"; |
| params[@"sms_code"] = @"0928"; |
| [OXClientEntry requestAction:OXActionTypeVerifyBySmsCheck params: params]; |
5.6、回调参数
成功
参数 |
类型 |
描述 |
action_type |
NSString |
请求类型 |
request_params |
NSDictionary |
请求参数 |
result |
code |
NSString |
返回码 |
verify_order_id |
NSString |
订单 ID (短信开启) |
verify_token |
NSString |
二次校验 token (短信验证) |
失败
参数 |
类型 |
描述 |
action_type |
NSString |
请求类型 |
request_params |
NSDictionary |
请求参数 |
result |
code |
NSString |
返回码 |
5.7、回调示例
| { |
| "action_type" = 4 |
| "request_params" = { |
| tel = 15506903077 |
| } |
| result = { |
| "code" = "00000" |
| "request_id" = 15946946946443699 |
| "verify_order_id" = "sms_159469469521288e78171f32d41c9aab7f5a8427a10c0" |
| } |
| } |
5.8、回调方法
| - (void)onActionResult:(NSDictionary *)result{ |
| if([result[@"action_type"] integerValue]== OXActionTypeVerifyBySmsStart){ |
| |
| } |
| if([result[@"action_type"] integerValue]== OXActionTypeVerifyBySmsCheck){ |
| |
| } |
| } |
5.9、注意事项
只支持国内手机号、有国际手机号需要请联系客服。
6、其它接口说明
获取当前网络信息和运营商信息,该接口可判断当前是否开启了 Wifi 和 蜂窝移动网络,并能准确判断当前对应的运营商
| |
| *网络类型及运营商(双卡下,获取上网卡的运营商) |
| *"carrier" 运营商:0.未知 / 1.中国移动 / 2.中国联通 / 3.中国电信 |
| *"networkType" 网络类型:0.无网络/ 1.数据流量 / 2.wifi / 3.数据+wifi |
| *@return @{NSString : NSNumber} |
| */ |
| + (NSDictionary<NSString *,NSNumber *> *)networkInfo; |
自定义一键登录授权页 UI 样式参数
| + (void)oneKeyCustomUIWithParams:(OXOneKeyCustomModel *)viewModel; |
关闭授权页、请不要使用其他方式关闭授权页,否则可能导致授权页无法再次调起
| + (void)dismissLoginPageAnimated: (BOOL)flag completion: (void (^)(void))completion; |
控制台日志输出控制(默认关闭)
| + (void)printConsoleEnable:(BOOL)enable; |
清除预取号缓存
| + (void)deletePreLoginCache; |
获取当前 SDK 版本
| + (NSString *)sdkVersion; |
获取本地越狱、调试、模拟器等状态 ( v2.3.2 以上版本 )
| + (NSDictionary *)getLocalDeviceEnv; |
参数 |
类型 |
描述 |
debugging |
NSString |
设备处于正在被调试状态 |
multiple_app_on |
NSString |
多开 |
root |
NSString |
越狱 |
simulator |
NSString |
模拟器操作 |
示例
| { |
| debugging = 1; |
| "multiple_app_on" = 0; |
| root = 1; |
| simulator = 0; |
| } |
7、授权页配置
7.1、设计规范
7.2、配置属性
7.2.1、自定义控件
属性名 |
类型 |
说明 |
customAreaView |
Block类型 |
添加自定义控件 |
loadingView |
Block类型 |
授权页自定义Loading |
webLoadingView |
Block类型 |
协议页自定义Loading |
toastView |
Block类型 |
添加自定义控件toast视图 |
7.2.2、功能开关
属性名 |
类型 |
说明 |
manualDismiss |
NSNumber(BOOL) |
设置dismiss管理权限 |
oxPresentViewControllerAnimated |
NSNumber(BOOL) |
授权页弹起动画开关 |
7.2.3、弹窗设置
属性名 |
类型 |
说明 |
oxAuthTypeUseWindow |
NSNumber(BOOL) |
以弹窗方式显示 |
oxAuthWindowCornerRadius |
NSNumber(CGFloat) |
弹窗圆角 |
oxAuthWindowModalTransitionStyle |
NSNumber(oxAuthWindowModalTransitionStyle) |
弹窗展示动画 |
oxAuthWindowOrientationCenter |
NSValue(CGPointMake) |
弹窗中心 |
oxAuthWindowOrientationWidth |
NSNumber(CGFloat) |
弹窗宽 |
oxAuthWindowOrientationHeight |
NSNumber(CGFloat) |
弹窗高 |
7.2.4、背景
属性名 |
类型 |
说明 |
oxBackgroundImg |
UIImage |
授权页-背景图片 |
7.2.5、状态栏
属性名= |
类型 |
说明 |
oxNavigationBarStyle |
NSNumber(UIBarStyle) |
状态栏颜色 UIBarStyleDefault:状态栏显示 黑 UIBarStyleBlack:状态栏显示 白
|
7.2.6、导航栏
属性名 |
类型 |
说明 |
oxNavigationBarHidden |
NSNumber(BOOL) |
导航栏 是否隐藏 |
oxNavigationBackgroundoxear |
NSNumber(BOOL) |
导航栏 背景透明 |
oxNavigationAttributesTitleText |
NSAttributedString |
导航栏标题 |
oxNavigationRightControl |
UIBarButtonItem |
导航栏右侧自定义按钮 |
oxNavigationLeftControl |
UIBarButtonItem |
导航栏左侧自定义按钮 |
oxNavigationBackBtnImage |
UIImage |
导航栏左侧返回按钮图片 |
oxNavigationBackBtnHidden |
NSNumber(BOOL) |
导航栏自带返回按钮隐藏 |
oxNavBackBtnImageInsets |
NSValue(UIEdgeInsetsMake) |
返回按钮图片缩进 |
oxNavigationBarTintColor |
UIColor |
导航栏 背景色 |
oxNavigationBackgroundImage |
UIImage |
导航栏 背景图片 |
oxNavigationShadowImage |
UIImage |
导航栏 导航栏底部分割线 |
7.2.7、LOGO
属性名 |
类型 |
说明 |
oxLogoImage |
UIImage |
LOGO图片 |
oxLogoCornerRadius |
NSNumber(CGFloat) |
LOGO圆角 |
oxLogoHiden |
NSNumber(BOOL) |
LOGO隐藏 |
7.2.8、手机号
属性名 |
类型 |
说明 |
oxPhoneNumberColor |
UIColor |
手机号颜色 |
oxPhoneNumberFont |
UIFont |
手机号字体 |
oxPhoneNumberTextAlignment |
NSNumber(NSTextAlignment) |
手机号对齐方式 |
7.2.9、登录按钮
属性名 |
类型 |
说明 |
oxLoginBtnText |
NSString |
按钮文字 |
oxLoginBtnTextColor |
UIColor |
按钮文字颜色 |
oxLoginBtnBgColor |
UIColor |
按钮背景颜色 |
oxLoginBtnTextFont |
UIFont |
按钮文字字体 |
oxLoginBtnNormalBgImage |
UIImage |
按钮背景图片 |
oxLoginBtnHightLightBgImage |
UIImage |
按钮背景高亮图片 |
oxLoginBtnBorderColor |
UIColor |
按钮边框颜色 |
oxLoginBtnCornerRadius |
NSNumber(CGFloat) |
按钮圆角 |
oxLoginBtnBorderWidth |
NSNumber(CGFloat) |
按钮边框 |
7.2.10、条款选择框
属性名 |
类型 |
说明 |
oxCheckBoxHidden |
NSNumber(BOOL) |
协议勾选框隐藏 |
oxCheckBoxValue |
NSNumber(BOOL) |
协议勾选框选中 |
oxCheckBoxSize |
NSValue(CGSizeMake) |
协议勾选框 |
oxCheckBoxImageEdgeInsets |
NSValue(UIEdgeInsetsMake) |
协议勾选框 图片缩进 |
oxCheckBoxUncheckedImage |
UIImage |
协议勾选框 非选中状态图片 |
oxCheckBoxCheckedImage |
UIImage |
协议勾选框 选中状态图片 |
7.2.11、隐私条款
属性名 |
类型 |
说明 |
oxAppTermsColor |
NSArray < UIColor *> |
隐私条款名称颜色 |
oxAppTermsTextFont |
UIFont |
隐私条款文字字体 |
oxAppTermsEdgeInsets |
NSValue(UIEdgeInsetsMake) |
隐私条款内边距 |
oxAppTermsTextAlignment |
NSNumber(NSTextAlignment) |
隐私条款文字对齐方式 |
oxAppTermsPunctuationMarks |
NSNumber(BOOL) |
运营商隐私条款书名号 |
oxAppTermsHeight |
CGFloat |
获取条款高度 |
oxAppTermsLineSpacing |
NSNumber(CGFloat) |
行间距 |
oxAppTermsNeedSizeToFit |
NSNumber(BOOL) |
是否需要sizeToFit |
oxTermsTemplate |
NSAttributedString |
隐私的内容模板 |
oxTerms |
NSArray < NSAttributedString *> |
隐私条款 |
7.2.12、协议页
属性名 |
类型 |
说明 |
oxAppTermsWebNavigationBarStyle |
NSNumber(UIBarStyle) |
状态栏颜色 UIBarStyleDefault:状态栏显示 黑 UIBarStyleBlack:状态栏显示 白
|
oxAppTermsWebTitle |
NSAttributedString |
协议页标题 |
oxAppTermsWebTitleAttributes |
NSDictionary |
协议页自带标题样式 |
oxAppTermsWebBackBtnImage |
UIImage |
隐私协议WEB页面导航返回按钮图片 |
oxWebNavigationBackgroundImage |
UIImage |
协议页导航栏背景图片 |
oxWebNavigationBarTintColor |
UIColor |
协议页导航栏背景颜色 |
oxAppTermsPageWindow |
NSNumber(BOOL) |
协议页开启弹框模式 |
oxAppTermsPageWindowRadius |
NSNumber(CGFloat) |
协议页弹框圆角 |
oxAppTermsPageWindowCloseHeight |
NSNumber(CGFloat) |
协议页弹框模式关闭按钮高度 |
oxAppTermsPageWindowCloseUIColor |
UIColor |
协议页弹框模式关闭按钮颜色 |
oxAppTermsPageWindowCloseText |
NSAttributedString |
协议页弹框模式关闭按钮文本 |
7.2.13、运营商标识
属性名 |
类型 |
说明 |
oxSloganTextFont |
UIFont |
slogan文字字体 |
oxSloganTextColor |
UIColor |
slogan文字颜色 |
oxSlogaTextAlignment |
NSNumber(NSTextAlignment) |
slogan文字对齐方式 |
7.2.14、Loading
属性名 |
类型 |
说明 |
oxLoadingSize |
NSValue(CGSizeMake) |
Loading 大小 |
oxLoadingCornerRadius |
NSNumber(CGFloat) |
Loading 圆角 |
oxLoadingBackgroundColor |
UIColor |
Loading 背景色 |
oxLoadingColor |
UIColor |
Loading 颜色 |
oxLoadingIndicatorStyle |
NSValue(UIActivityIndicatorViewStyle) |
Loading动画 |
7.2.15、toast视图
属性名 |
类型 |
说明 |
oxShowToast |
NSNumber(BOOL) |
是否开启toast视图 |
oxShowToastStr |
NSString |
toast文本 |
oxShowToastTime |
NSNumber(CGFloat) |
toast视图显示时常 |
7.2.16、横竖屏设置
属性名 |
类型 |
说明 |
oxShouldAutorotate |
NSNumber(BOOL) |
是否支持自动旋转 |
oxSupportedInterfaceOrientations |
NSNumber(UIInterfaceOrientationMask) |
支持方向 |
7.2.17、授权页布局
属性名 |
类型 |
说明 |
oxOrientationLayOutPortrait |
OXOrientationLayOut |
竖屏布局配置对象 -->创建一个布局对象,设置好控件约束属性值,再设置到此属性中 |
oxOrientationLayOutLandscape |
OXOrientationLayOut |
横屏布局配置对象 -->创建一个布局对象,设置好控件约束属性值,再设置到此属性中 |
7.2.18、OXOrientationLayOut布局设置
LOGO
属性名 |
类型 |
说明 |
oxLayoutLogoLeft |
NSNumber(CGFloat) |
左边距 |
oxLayoutLogoTop |
NSNumber(CGFloat) |
上边距 |
oxLayoutLogoRight |
NSNumber(CGFloat) |
右边距 |
oxLayoutLogoBottom |
NSNumber(CGFloat) |
下边距 |
oxLayoutLogoWidth |
NSNumber(CGFloat) |
宽 |
oxLayoutLogoHeight |
NSNumber(CGFloat) |
高 |
oxLayoutLogoCenterX |
NSNumber(CGFloat) |
X轴居中 |
oxLayoutLogoCenterY |
NSNumber(CGFloat) |
Y轴居中 |
手机号
属性名 |
类型 |
说明 |
oxLayoutPhoneLeft |
NSNumber(CGFloat) |
左边距 |
oxLayoutPhoneTop |
NSNumber(CGFloat) |
上边距 |
oxLayoutPhoneRight |
NSNumber(CGFloat) |
右边距 |
oxLayoutPhoneBottom |
NSNumber(CGFloat) |
下边距 |
oxLayoutPhoneWidth |
NSNumber(CGFloat) |
宽 |
oxLayoutPhoneHeight |
NSNumber(CGFloat) |
高 |
oxLayoutPhoneCenterX |
NSNumber(CGFloat) |
X轴居中 |
oxLayoutPhoneCenterY |
NSNumber(CGFloat) |
Y轴居中 |
slogan
属性名 |
类型 |
说明 |
oxLayoutSloganLeft |
NSNumber(CGFloat) |
左边距 |
oxLayoutSloganTop |
NSNumber(CGFloat) |
上边距 |
oxLayoutSloganRight |
NSNumber(CGFloat) |
右边距 |
oxLayoutSloganBottom |
NSNumber(CGFloat) |
下边距 |
oxLayoutSloganWidth |
NSNumber(CGFloat) |
宽 |
oxLayoutSloganHeight |
NSNumber(CGFloat) |
高 |
oxLayoutSloganCenterX |
NSNumber(CGFloat) |
X轴居中 |
oxLayoutSloganCenterY |
NSNumber(CGFloat) |
Y轴居中 |
登录按钮
属性名 |
类型 |
说明 |
oxLayoutLoginBtnLeft |
NSNumber(CGFloat) |
左边距 |
oxLayoutLoginBtnTop |
NSNumber(CGFloat) |
上边距 |
oxLayoutLoginBtnRight |
NSNumber(CGFloat) |
右边距 |
oxLayoutLoginBtnBottom |
NSNumber(CGFloat) |
下边距 |
oxLayoutLoginBtnWidth |
NSNumber(CGFloat) |
宽 |
oxLayoutLoginBtnHeight |
NSNumber(CGFloat) |
高 |
oxLayoutLoginBtnCenterX |
NSNumber(CGFloat) |
X轴居中 |
oxLayoutLoginBtnCenterY |
NSNumber(CGFloat) |
Y轴居中 |
隐私条款
属性名 |
类型 |
说明 |
oxLayoutAppTermsLeft |
NSNumber(CGFloat) |
左边距 |
oxLayoutAppTermsTop |
NSNumber(CGFloat) |
上边距 |
oxLayoutAppTermsRight |
NSNumber(CGFloat) |
右边距 |
oxLayoutAppTermsBottom |
NSNumber(CGFloat) |
下边距 |
oxLayoutAppTermsWidth |
NSNumber(CGFloat) |
宽 |
oxLayoutAppTermsHeight |
NSNumber(CGFloat) |
高 |
oxLayoutAppTermsCenterX |
NSNumber(CGFloat) |
X轴居中 |
oxLayoutAppTermsCenterY |
NSNumber(CGFloat) |
Y轴居中 |
弹窗协议页
属性名 |
类型 |
说明 |
oxLayoutAppTermsPageLeft |
NSNumber(CGFloat) |
左边距 |
oxLayoutAppTermsPageTop |
NSNumber(CGFloat) |
上边距 |
oxLayoutAppTermsPageRight |
NSNumber(CGFloat) |
右边距 |
oxLayoutAppTermsPageBottom |
NSNumber(CGFloat) |
下边距 |
oxLayoutAppTermsPageWidth |
NSNumber(CGFloat) |
宽 |
oxLayoutAppTermsPageHeight |
NSNumber(CGFloat) |
高 |
oxLayoutAppTermsPageCenterX |
NSNumber(CGFloat) |
X轴居中 |
oxLayoutAppTermsPageCenterY |
NSNumber(CGFloat) |
Y轴居中 |
7.3、横竖屏弹窗
7.3.1、相关配置属性
| #pragma mark - 窗口授权页设置 |
| |
| *以窗口方式显示 |
| *类型:BOOL, default is NO |
| *eg.@(YES) |
| */ |
| @property (nonatomic,strong) NSNumber * oxAuthTypeUseWindow; |
| |
| *窗口圆角 |
| *类型:CGFloat |
| *eg.@(10) |
| */ |
| @property (nonatomic,strong) NSNumber * oxAuthWindowCornerRadius; |
| |
| *窗口展示动画 |
| *oxAuthWindowModalTransitionStyle系统自带的弹出方式 仅支持以下三种 |
| *UIModalTransitionStyleCoverVertical 底部弹出 |
| *UIModalTransitionStyleCrossDissolve 淡入 |
| *UIModalTransitionStyleFlipHorizontal 翻转显示 |
| */ |
| @property (nonatomic,strong) NSNumber * oxAuthWindowModalTransitionStyle; |
| |
| *窗口中心:CGPoint X Y |
| */ |
| @property (nonatomic,strong) NSValue * oxAuthWindowOrientationCenter; |
| |
| *窗口大小:宽 float |
| */ |
| @property (nonatomic,strong) NSNumber * oxAuthWindowOrientationWidth; |
| |
| *窗口大小:高 float |
| */ |
| @property (nonatomic,strong) NSNumber * oxAuthWindowOrientationHeight; |
| #pragma mark - 横竖屏设置 |
| |
| *是否支持自动旋转 BOOL |
| *类型:BOOL,default is NO |
| *eg.@(YES) |
| */ |
| @property (nonatomic,strong) NSNumber * oxShouldAutorotate; |
| |
| *支持方向 UIInterfaceOrientationMask |
| *如果设置只支持竖屏,只需设置oxOrientationLayOutPortrait竖屏布局对象 |
| *如果设置只支持横屏,只需设置oxOrientationLayOutLandscape横屏布局对象 |
| *横竖屏均支持,需同时设置oxOrientationLayOutPortrait和oxOrientationLayOutLandscape |
| */ |
| @property (nonatomic,strong) NSNumber * oxSupportedInterfaceOrientations; |
7.3.2、使用示例
| OXOneKeyCustomModel *model = [[OXOneKeyCustomModel alloc] init]; |
| model.oxAuthTypeUseWindow = @(YES); |
| model.oxAuthWindowCornerRadius = @(5); |
| model.oxAuthWindowModalTransitionStyle = @(UIModalTransitionStyleFlipHorizontal); |
| |
| |
| |
| |
| model.oxOrientationLayOutPortrait = [self setWindowLayoutPortrait]; |
| model.oxOrientationLayOutLandscape = [self setWindowLayoutLandscape]; |
| |
| [OXClientEntry oneKeyCustomUIWithParams:model]; |
| |
| [OXClientEntry requestAction:OXActionTypeGetOnekeyLoginToken params:@{OXCurrentVC:self,@"timeout":@"5"}}]; |
| |
| -(OXOrientationLayOut *)setWindowLayoutPortrait{ |
| CGFloat ratio; |
| if (TEST_SCREEN_WIDTH>TEST_SCREENH_HEIGHT) { |
| ratio = TEST_SCREENH_HEIGHT/375; |
| }else{ |
| ratio = TEST_SCREEN_WIDTH/375; |
| } |
| OXOrientationLayOut *oxOrientationLayOutPortrait = [OXOrientationLayOut new]; |
| oxOrientationLayOutPortrait.oxAuthWindowOrientationWidth = @(ratio*330); |
| oxOrientationLayOutPortrait.oxAuthWindowOrientationHeight = @(ratio*400); |
| oxOrientationLayOutPortrait.oxAuthWindowOrientationCenter = [NSValue valueWithCGPoint:CGPointMake([UIScreen mainScreen].bounds.size.width/2, [UIScreen mainScreen].bounds.size.height/2)]; |
| |
| oxOrientationLayOutPortrait.oxLayoutLogoTop = @(10); |
| oxOrientationLayOutPortrait.oxLayoutLogoWidth = @(ratio*60); |
| oxOrientationLayOutPortrait.oxLayoutLogoHeight = @(ratio*60); |
| oxOrientationLayOutPortrait.oxLayoutLogoCenterX = @(0); |
| |
| oxOrientationLayOutPortrait.oxLayoutPhoneTop = @(ratio*70); |
| oxOrientationLayOutPortrait.oxLayoutPhoneWidth = @(ratio*200); |
| oxOrientationLayOutPortrait.oxLayoutPhoneHeight = @(ratio*40); |
| oxOrientationLayOutPortrait.oxLayoutPhoneCenterX = @(0); |
| |
| oxOrientationLayOutPortrait.oxLayoutLoginBtnTop = @(ratio*120); |
| oxOrientationLayOutPortrait.oxLayoutLoginBtnWidth = @(ratio*280); |
| oxOrientationLayOutPortrait.oxLayoutLoginBtnHeight = @(ratio*40); |
| oxOrientationLayOutPortrait.oxLayoutLoginBtnCenterX = @(0); |
| |
| oxOrientationLayOutPortrait.oxLayoutSloganTop = @(ratio*160); |
| oxOrientationLayOutPortrait.oxLayoutSloganWidth = @(ratio*300); |
| oxOrientationLayOutPortrait.oxLayoutSloganHeight = @(ratio*40); |
| oxOrientationLayOutPortrait.oxLayoutSloganCenterX = @(0); |
| |
| oxOrientationLayOutPortrait.oxLayoutAppTermsBottom = @(-10); |
| oxOrientationLayOutPortrait.oxLayoutAppTermsCenterX = @(0); |
| oxOrientationLayOutPortrait.oxLayoutAppTermsWidth = @(ratio*280); |
| |
| |
| oxOrientationLayOutPortrait.oxLayoutAppTermsPageWidth = @(300); |
| oxOrientationLayOutPortrait.oxLayoutAppTermsPageHeight = @(400); |
| oxOrientationLayOutPortrait.oxLayoutAppTermsPageCenterX = @(0); |
| oxOrientationLayOutPortrait.oxLayoutAppTermsPageCenterY = @(0); |
| return oxOrientationLayOutPortrait; |
| } |
| |
| -(OXOrientationLayOut *)setWindowLayoutLandscape{ |
| CGFloat ratio; |
| if (TEST_SCREEN_WIDTH>TEST_SCREENH_HEIGHT) { |
| ratio = TEST_SCREENH_HEIGHT/375; |
| }else{ |
| ratio = TEST_SCREEN_WIDTH/375; |
| } |
| OXOrientationLayOut *oxOrientationLayOutLandscape = [OXOrientationLayOut new]; |
| oxOrientationLayOutLandscape.oxAuthWindowOrientationWidth = @(ratio*400); |
| oxOrientationLayOutLandscape.oxAuthWindowOrientationHeight = @(ratio*250); |
| oxOrientationLayOutLandscape.oxAuthWindowOrientationCenter = [NSValue valueWithCGPoint:CGPointMake([UIScreen mainScreen].bounds.size.width/2, [UIScreen mainScreen].bounds.size.height/2)]; |
| |
| oxOrientationLayOutLandscape.oxLayoutLogoLeft = @(ratio*90); |
| oxOrientationLayOutLandscape.oxLayoutLogoTop = @(0); |
| oxOrientationLayOutLandscape.oxLayoutLogoWidth = @(ratio*60); |
| oxOrientationLayOutLandscape.oxLayoutLogoHeight = @(ratio*60); |
| |
| oxOrientationLayOutLandscape.oxLayoutPhoneLeft = @(ratio*120); |
| oxOrientationLayOutLandscape.oxLayoutPhoneTop = @(0); |
| oxOrientationLayOutLandscape.oxLayoutPhoneWidth = @(ratio*200); |
| oxOrientationLayOutLandscape.oxLayoutPhoneHeight = @(ratio*40); |
| |
| oxOrientationLayOutLandscape.oxLayoutLoginBtnTop = @(ratio*85); |
| oxOrientationLayOutLandscape.oxLayoutLoginBtnWidth = @(ratio*300); |
| oxOrientationLayOutLandscape.oxLayoutLoginBtnHeight = @(ratio*40); |
| oxOrientationLayOutLandscape.oxLayoutLoginBtnCenterX = @(0); |
| |
| oxOrientationLayOutLandscape.oxLayoutSloganLeft = @(ratio*120); |
| oxOrientationLayOutLandscape.oxLayoutSloganTop = @(ratio*30); |
| oxOrientationLayOutLandscape.oxLayoutSloganWidth = @(ratio*200); |
| oxOrientationLayOutLandscape.oxLayoutSloganHeight = @(ratio*40); |
| |
| oxOrientationLayOutLandscape.oxLayoutAppTermsBottom = @(-5); |
| oxOrientationLayOutLandscape.oxLayoutAppTermsWidth = @(ratio*300); |
| |
| oxOrientationLayOutLandscape.oxLayoutAppTermsCenterX = @(0); |
| return oxOrientationLayOutLandscape; |
| } |
7.3.3、弹窗添加蒙版
| |
| |
| 功能服务回调 |
| @param result 回调结果 |
| */ |
| -(void)onActionResult:(NSDictionary *)result{ |
| NSString *code = [NSString stringWithFormat:@"%@",result[@"result"][@"code"]]; |
| NSInteger action_type = [NSString stringWithFormat:@"%@",result[@"action_type"]].integerValue; |
| switch (action_type) { |
| case OXActionTypeGetOnekeyLoginToken: |
| if([code isEqualToString:@"45033"]){ |
| [self showWindowMask]; |
| }else{ |
| [self removeWindowMask]; |
| if ([code isEqualToString:@"00000"]) { |
| [[OXHUD sharedHUD] showMessage:@"获取token成功"]; |
| }else{ |
| [self HudShowWithStr:@"一键登录" code:code]; |
| } |
| } |
| break; |
| default: |
| break; |
| } |
| } |
| |
| -(void)showWindowMask{ |
| UIView * windowMask = [self.view viewWithTag:2019]; |
| if (windowMask == nil) { |
| windowMask = [[UIView alloc]initWithFrame:self.view.bounds]; |
| windowMask.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.4]; |
| windowMask.tag = 2019; |
| } |
| [self.view addSubview:windowMask]; |
| [windowMask mas_makeConstraints:^(MASConstraintMaker *make) { |
| make.edges.insets(UIEdgeInsetsZero); |
| }]; |
| } |
| |
| -(void)removeWindowMask{ |
| dispatch_async(dispatch_get_main_queue(), ^{ |
| UIView * windowMask = [self.view viewWithTag:2019]; |
| [windowMask removeFromSuperview]; |
| }); |
| } |
7.4、自定义控件
7.4.1、相关配置属性
| |
| *添加自定义控件 |
| *自定义控件坐标原点为屏幕左上角 |
| *可设置背景色及添加控件 |
| *横竖屏需要自主适配 |
| **/ |
| @property (nonatomic,copy,nullable)void(^customAreaView)(UIView * customAreaView); |
7.4.2、使用示例
| model.customAreaView = ^(UIView * _Nonnull customAreaView) { |
| |
| customAreaView.backgroundColor = [UIColor blackColor]; |
| UIImageView *backGroundImg = [[YYAnimatedImageView alloc] init]; |
| backGroundImg.image = [YYImage imageNamed:@"2019_P.gif"]; |
| [customAreaView addSubview:backGroundImg]; |
| UIButton * threeLogin= [[UIButton alloc] init]; |
| threeLogin.center = CGPointMake(self.view.center.x, threeLogin.center.y); |
| [threeLogin setTitle:@"其它方式登录" forState:UIControlStateNormal]; |
| threeLogin.backgroundColor = [[UIColor whiteColor] colorWithAlphaComponent:0.3]; |
| [threeLogin addTarget:self action:@selector(threeLoginClick) forControlEvents:UIControlEventTouchUpInside]; |
| [customAreaView addSubview:threeLogin]; |
| |
| UIButton *help = [[UIButton alloc] init]; |
| help.titleLabel.font = [UIFont systemFontOfSize:12]; |
| [help setTitleColor:TEST_HEXCOLOR(0xEEC900) forState:UIControlStateNormal]; |
| [help setTitle:@"登录遇到问题" forState: UIControlStateNormal]; |
| [help addTarget:self action:@selector(helpBtnClick) forControlEvents:UIControlEventTouchUpInside]; |
| help.backgroundColor = [UIColor clearColor]; |
| [customAreaView addSubview:help]; |
| |
| |
| |
| }; |
| -(void)helpBtnClick{ |
| [[OXHUD sharedHUD]showMessage:@"获取帮助"]; |
| } |
7.5、自定义授权页loading
7.5.1、相关配置属性
| |
| *授权页自定义Loading |
| * containerView为loading的全屏蒙版view |
| * 请自行在containerView添加自定义loading |
| * 设置block后,上述loading属性将无效 |
| * 横竖屏位置居中 |
| * 目前只支持居中设置 |
| */ |
| @property (nonatomic,copy,nullable)void(^loadingView)(UIView * containerView); |
7.5.2、使用示例
| model.loadingView = ^(UIView * _Nonnull containerView) { |
| UIImage *image = [YYImage imageNamed:@"loading.gif"]; |
| UIImageView *imageBackground = [[YYAnimatedImageView alloc] initWithImage:image]; |
| imageBackground.frame = CGRectMake(0, 0, 80, 80); |
| imageBackground.center = containerView.center; |
| imageBackground.layer.cornerRadius = 40; |
| imageBackground.layer.masksToBounds = YES; |
| [containerView addSubview:imageBackground]; |
| }; |
7.6、自定义协议页loading
7.6.1、相关配置属性
| |
| *协议页自定义Loading |
| *containerView为loading的全屏蒙版view |
| *请自行在containerView添加自定义loading |
| *横竖屏位置居中 |
| *目前只支持居中设置 |
| */ |
| @property (nonatomic,copy,nullable)void(^webLoadingView)(UIView * containerView); |
7.6.2、使用示例
| model.webLoadingView = ^(UIView * _Nonnull containerView) { |
| UIImage *image = [YYImage imageNamed:@"loading.gif"]; |
| UIImageView *imageBackground = [[YYAnimatedImageView alloc] initWithImage:image]; |
| [containerView addSubview:imageBackground]; |
| imageBackground.frame = CGRectMake(0, 0, 80, 80); |
| imageBackground.center = containerView.center; |
| imageBackground.layer.cornerRadius = 40; |
| imageBackground.layer.masksToBounds = YES; |
| }; |
7.7、自定义toast视图
7.7.1、相关配置属性
| |
| *添加自定义控件toast视图 |
| *未勾选协议时点击一键登录按钮触发 |
| *视图在规定时间内移除 |
| *默认1.5s |
| *横竖屏需要自主适配 |
| */ |
| @property (nonatomic,copy,nullable)void(^toastView)(UIView * containerView); |
7.7.2、使用示例
| model.toastView = ^(UIView * _Nonnull containerView) { |
| NSString *message =@"你还没勾选协议呢"; |
| UIView *showview = [[UIView alloc]init]; |
| showview.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:.3]; |
| showview.frame = CGRectMake(1, 1, 1, 1); |
| showview.layer.cornerRadius = 5.0f; |
| showview.layer.masksToBounds = YES; |
| [containerView addSubview:showview]; |
| UILabel *label = [[UILabel alloc]init]; |
| NSDictionary *attribute = @{NSFontAttributeName: [UIFont systemFontOfSize:17]}; |
| CGSize LabelSize = [message boundingRectWithSize:CGSizeMake(290, 9000) |
| options:NSStringDrawingTruncatesLastVisibleLine|NSStringDrawingUsesLineFragmentOrigin|NSStringDrawingUsesFontLeading |
| attributes:attribute context:nil].size; |
| label.frame = CGRectMake(10, 5, LabelSize.width, LabelSize.height); |
| label.text = message; |
| label.textColor = [UIColor whiteColor]; |
| label.textAlignment = 1; |
| label.backgroundColor = [UIColor clearColor]; |
| label.font = [UIFont boldSystemFontOfSize:15]; |
| [showview addSubview:label]; |
| showview.frame = CGRectMake((containerView .frame.size.width - LabelSize.width - 20)/2, containerView .frame.size.height - LabelSize.height-100, LabelSize.width+20, LabelSize.height+10); |
| }; |
具体设置请参考demo
四、错误码
点击查看错误码列表
五、FAQ
点击查看FAQ