### NSLayoutConstraint Verbose Implementation Source: https://github.com/yidun/ntesquickpass/blob/master/Demo/NTESQuickPassPublicDemo/Pods/Masonry/README.md An example demonstrating the verbose nature of standard NSLayoutConstraint when attempting to inset a view within its superview by 10 pixels on all sides. ```obj-c UIView *superview = self.view; UIView *view1 = [[UIView alloc] init]; view1.translatesAutoresizingMaskIntoConstraints = NO; view1.backgroundColor = [UIColor greenColor]; [superview addSubview:view1]; UIEdgeInsets padding = UIEdgeInsetsMake(10, 10, 10, 10); [superview addConstraints:@[ //view1 constraints [NSLayoutConstraint constraintWithItem:view1 attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:superview attribute:NSLayoutAttributeTop multiplier:1.0 constant:padding.top], [NSLayoutConstraint constraintWithItem:view1 attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:superview attribute:NSLayoutAttributeLeft multiplier:1.0 constant:padding.left], [NSLayoutConstraint constraintWithItem:view1 attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:superview attribute:NSLayoutAttributeBottom multiplier:1.0 constant:-padding.bottom], [NSLayoutConstraint constraintWithItem:view1 attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:superview attribute:NSLayoutAttributeRight multiplier:1 constant:-padding.right], ]]; ``` -------------------------------- ### Constraint with MASViewAttribute Source: https://github.com/yidun/ntesquickpass/blob/master/Demo/NTESQuickPassPublicDemo/Pods/Masonry/README.md Example of using MASViewAttribute for relative positioning. ```obj-c make.centerX.lessThanOrEqualTo(view2.mas_left); ``` -------------------------------- ### Remake Constraints with mas_remakeConstraints Source: https://github.com/yidun/ntesquickpass/blob/master/Demo/NTESQuickPassPublicDemo/Pods/Masonry/README.md Use mas_remakeConstraints to remove all existing constraints and install new ones, avoiding the need to keep references. ```obj-c - (void)changeButtonPosition { [self.button mas_remakeConstraints:^(MASConstraintMaker *make) { make.size.equalTo(self.buttonSize); if (topLeft) { make.top.and.left.offset(10); } else { make.bottom.and.right.offset(-10); } }]; } ``` -------------------------------- ### 判断运营商环境 Source: https://github.com/yidun/ntesquickpass/blob/master/doc/一键登录iOS SDK接入指南.md 在执行一键登录前,调用shouldQuickLogin判断当前网络环境是否支持一键登录。 ```objective-c BOOL shouldQuickLogin = [self.manager shouldQuickLogin]; ``` -------------------------------- ### 引入 SDK 头文件 Source: https://github.com/yidun/ntesquickpass/blob/master/doc/本机验证 iOS SDK接入指南.md 在需要使用 SDK 的文件中引入头文件。 ```objective-c #import ``` -------------------------------- ### NTESQuickLoginManager 初始化与预取号 Source: https://github.com/yidun/ntesquickpass/blob/master/doc/一键登录iOS SDK接入指南.md 初始化 SDK 并调用预取号接口,获取 token 以便后续进行登录校验。 ```APIDOC ## [Method] registerWithBusinessID ### Description 初始化易盾 SDK,需传入业务 ID。 ### Signature [[NTESQuickLoginManager sharedInstance] registerWithBusinessID:@"businessID"]; ## [Method] getPhoneNumberCompletion ### Description 执行预取号操作,获取 token。 ### Signature [[NTESQuickLoginManager sharedInstance] getPhoneNumberCompletion:^(NSDictionary * _Nonnull resultDic) { ... }]; ### Parameters - **resultDic** (NSDictionary) - 包含 success (BOOL) 和 token (NSString) 的结果字典。 ``` -------------------------------- ### 初始化与预取号 Source: https://github.com/yidun/ntesquickpass/blob/master/doc/一键登录iOS SDK接入指南.md 使用业务ID初始化SDK并调用预取号接口,成功后可进行UI配置与授权登录。 ```objective-c /// 初始化易盾 SDK [[NTESQuickLoginManager sharedInstance] registerWithBusinessID:@"请输入易盾业务ID"]; __weak __typeof__(self) weakSelf = self; [[NTESQuickLoginManager sharedInstance] getPhoneNumberCompletion:^(NSDictionary * _Nonnull resultDic) { NSNumber *boolNum = [resultDic objectForKey:@"success"]; weakSelf.token = [resultDic objectForKey:@"token"]; weakSelf.resultDic = resultDic; BOOL success = [boolNum boolValue]; if (success) { [weakSelf setCustomUI]; [weakSelf authorizeLogin]; } else { /// 预取号失败走降级处理 } }]; ``` -------------------------------- ### Create constraints with MASConstraintMaker Source: https://github.com/yidun/ntesquickpass/blob/master/Demo/NTESQuickPassPublicDemo/Pods/Masonry/README.md Demonstrates creating edge constraints using MASConstraintMaker with UIEdgeInsets. ```obj-c UIEdgeInsets padding = UIEdgeInsetsMake(10, 10, 10, 10); [view1 mas_makeConstraints:^(MASConstraintMaker *make) { make.top.equalTo(superview.mas_top).with.offset(padding.top); //with is an optional semantic filler make.left.equalTo(superview.mas_left).with.offset(padding.left); make.bottom.equalTo(superview.mas_bottom).with.offset(-padding.bottom); make.right.equalTo(superview.mas_right).with.offset(-padding.right); }]; ``` -------------------------------- ### 执行授权登录 Source: https://github.com/yidun/ntesquickpass/blob/master/doc/一键登录iOS SDK接入指南.md 调用授权登录接口获取accessToken,用于后续服务端校验。 ```objective-c - (void)authorizeLogin { [[NTESQuickLoginManager sharedInstance] CUCMCTAuthorizeLoginCompletion:^(NSDictionary * _Nonnull resultDic) { NSNumber *boolNum = [resultDic objectForKey:@"success"]; BOOL success = [boolNum boolValue]; if (success) { self.accessToken = [resultDic objectForKey:@"accessToken"]; /// 预取号和取号分别获取的token、accessToken,到服务端校验。 } else { /// 取号失败走降级处理 } }]; } ``` -------------------------------- ### Setting Constraint Priorities Source: https://github.com/yidun/ntesquickpass/blob/master/Demo/NTESQuickPassPublicDemo/Pods/Masonry/README.md Demonstrates how to apply priority levels to constraint chains using .priorityLow() or specific numeric values with .priority(). ```obj-c make.left.greaterThanOrEqualTo(label.mas_left).with.priorityLow(); make.top.equalTo(label.mas_top).with.priority(600); ``` -------------------------------- ### 通过 CocoaPods 集成 SDK Source: https://github.com/yidun/ntesquickpass/blob/master/doc/一键登录iOS SDK接入指南.md 在 Podfile 中添加 NTESQuickPass 依赖以集成 SDK。支持集成最新版本或指定特定版本。 ```ruby # 以下两种版本选择方式示例 source 'https://github.com/CocoaPods/Specs.git' // 指定下载源 # 集成最新版SDK: pod 'NTESQuickPass' # 集成指定SDK,具体版本号可先执行 pod search NTESQuickPass,根据返回的版本信息自行决定: pod 'NTESQuickPass', '3.2.3' ``` -------------------------------- ### Using MASCompositeConstraints for Size Source: https://github.com/yidun/ntesquickpass/blob/master/Demo/NTESQuickPassPublicDemo/Pods/Masonry/README.md Demonstrates constraining both width and height of a view, including offset adjustments. ```obj-c // make width and height greater than or equal to titleLabel make.size.greaterThanOrEqualTo(titleLabel) // make width = superview.width + 100, height = superview.height - 50 make.size.equalTo(superview).sizeOffset(CGSizeMake(100, -50)) ``` -------------------------------- ### 获取 SDK 版本号 Source: https://github.com/yidun/ntesquickpass/blob/master/doc/本机验证 iOS SDK接入指南.md 获取当前 SDK 的版本号字符串。 ```objective-c /** 获取当前SDK版本号 */ - (NSString *)getSDKVersion; ``` -------------------------------- ### Add NTESQuickPass to Podfile Source: https://github.com/yidun/ntesquickpass/blob/master/Demo/NTESQuickPassPublicDemo/Pods/NTESQuickPass/README.md Add the dependency to your Podfile. You can choose to integrate the latest version or a specific version of the SDK. ```ruby # 以下两种版本选择方式示例 # 集成最新版SDK: pod 'NTESQuickPass' # 集成指定SDK,具体版本号可先执行 pod search NTESQuickPass,根据返回的版本信息自行决定: pod 'NTESQuickPass', '~> 3.3.7' ``` -------------------------------- ### 设置超时时间属性 Source: https://github.com/yidun/ntesquickpass/blob/master/doc/本机验证 iOS SDK接入指南.md 设置获取 accessToken 的超时时间,单位为 ms。 ```objective-c /** * @abstract 属性 * * @说明 设置获取accessToken的超时时间,单位ms,不传或传0默认3000ms,最大不超过10000ms */ @property (nonatomic, assign) NSTimeInterval timeOut; ``` -------------------------------- ### Using MASCompositeConstraints for Center Source: https://github.com/yidun/ntesquickpass/blob/master/Demo/NTESQuickPassPublicDemo/Pods/Masonry/README.md Shows how to align the center of a view to another view or superview with optional offsets. ```obj-c // make centerX and centerY = button1 make.center.equalTo(button1) // make centerX = superview.centerX - 5, centerY = superview.centerY + 10 make.center.equalTo(superview).centerOffset(CGPointMake(-5, 10)) ``` -------------------------------- ### 初始化SDK Source: https://github.com/yidun/ntesquickpass/blob/master/doc/一键登录iOS SDK接入指南.md 在视图控制器的viewDidLoad方法中引入头文件并调用registerWithBusinessID进行初始化。 ```objective-c - (void)viewDidLoad { [super viewDidLoad]; // 初始化 SDK self.manager = [NTESQuickLoginManager sharedInstance]; [self.manager registerWithBusinessID:@"yourBusinessID"]; } ``` -------------------------------- ### 拉取授权页接口调用 Source: https://github.com/yidun/ntesquickpass/blob/master/doc/一键登录iOS SDK接入指南.md 调用此接口弹出运营商授权页面。建议在预取号成功后调用,且已登录状态下不要调用。 ```objective-c [[NTESQuickLoginManager sharedInstance] CUCMCTAuthorizeLoginCompletion:^(NSDictionary * _Nonnull resultDic) { NSNumber *boolNum = [resultDic objectForKey:@"success"]; BOOL success = [boolNum boolValue]; if (success) { // 取号成功,获取acessToken } else { // 取号失败 } } animated:NO]; ``` -------------------------------- ### 配置登录页面UI Source: https://github.com/yidun/ntesquickpass/blob/master/doc/一键登录iOS SDK接入指南.md 通过NTESQuickLoginModel设置登录页面的外观属性、隐私协议及各类交互回调。 ```objective-c - (void)setCustomUI { NTESQuickLoginModel *model = [[NTESQuickLoginModel alloc] init]; model.presentDirectionType = NTESPresentDirectionPush; model.navTextColor = [UIColor blueColor]; model.navBgColor = [UIColor whiteColor]; model.authWindowPop = NTESAuthWindowPopFullScreen; model.backgroundColor = [UIColor whiteColor]; /// logo model.logoImg = [UIImage imageNamed:@"login_logo-1"]; model.logoWidth = 52; model.logoHeight = 52; model.logoHidden = NO; /// 手机号码 model.numberFont = [UIFont fontWithName:@"PingFangSC-Semibold" size:18]; model.numberOffsetX = 0; model.numberHeight = 27; /// 品牌 model.brandFont = [UIFont fontWithName:@"PingFangSC-Regular" size:12]; model.brandWidth = 200; model.brandBackgroundColor = [UIColor clearColor]; model.brandHeight = 20; model.brandOffsetX = 0; /// 登录按钮 model.logBtnTextFont = [UIFont systemFontOfSize:14]; model.logBtnTextColor = [UIColor whiteColor]; model.logBtnText = @"确定登录"; model.logBtnRadius = 8; model.logBtnHeight = 44; model.startPoint = CGPointMake(0, 0.5); model.endPoint = CGPointMake(1, 0.5); model.colors = @[(__bridge id)[UIColor redColor].CGColor, (__bridge id)[UIColor yellowColor].CGColor]; /// 隐私协议 model.appPrivacyText = @"登录即同意《默认》并授权《用户协议》和《隐私协议》获得本机号码"; model.appFPrivacyText = @"《用户协议》"; model.appPrivacyOriginBottomMargin = 50; model.appFPrivacyURL = @"https://support.dun.163.com/documents/287305921855672320?docId=429869784953151488"; model.appSPrivacyText = @"《隐私协议》"; model.appFPrivacyURL = @"https://support.dun.163.com/documents/287305921855672320?docId=429869784953151488"; model.shouldHiddenPrivacyMarks = YES; model.uncheckedImg = [[UIImage imageNamed:@"login_kuang"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]; model.checkedImg = [[UIImage imageNamed:@"login_kuang_gou"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]; model.checkboxWH = 11; model.privacyState = YES; model.isOpenSwipeGesture = NO; model.privacyFont = [UIFont fontWithName:@"PingFangSC-Regular" size:11]; model.statusBarStyle = UIStatusBarStyleLightContent; model.customViewBlock = ^(UIView * _Nullable customView) { UILabel *otherLabel = [[UILabel alloc] init]; otherLabel.userInteractionEnabled = YES; otherLabel.text = @"其他登录方式"; otherLabel.textAlignment = NSTextAlignmentCenter; otherLabel.textColor = [UIColor ntes_colorWithHexString:@"#324DFF"]; otherLabel.font = [UIFont fontWithName:@"PingFangSC-Regular" size:12]; [customView addSubview:otherLabel]; [otherLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.centerX.equalTo(customView); make.top.equalTo(customView).mas_offset(339); make.height.mas_equalTo(16); }]; }; /**返回按钮点击事件回调*/ model.backActionBlock = ^{ NSLog(@"返回按钮点击"); }; /**登录按钮点击事件回调*/ model.loginActionBlock = ^{ NSLog(@"loginAction"); }; /**复选框点击事件回调*/ model.checkActionBlock = ^(BOOL isChecked) { if (isChecked) { //选中复选框; } else { //取消复选框; } }; /**协议点击事件回调*/ model.privacyActionBlock = ^(int privacyType) { if (privacyType == 0) { //点击默认协议 } else if (privacyType == 1) { // 点击自定义第1个协议; } else if (privacyType == 2) { // 点击自定义第1个协议; } }; /**协议点击事件回调,不会跳转到默认的协议页面。开发者可以在回调里,自行跳转到自定义的协议页面*/ model.pageCustomBlock = ^{ // 跳转到自定义的控制器 }; [[NTESQuickLoginManager sharedInstance] setupModel:model]; } ``` -------------------------------- ### 初始化 SDK Source: https://github.com/yidun/ntesquickpass/blob/master/doc/本机验证 iOS SDK接入指南.md 在页面初始化时获取 SDK 管理器实例。 ```objective-c - (void)viewDidLoad { [super viewDidLoad]; // sdk调用 self.manager = [NTESQuickPassManager sharedInstance]; } ``` -------------------------------- ### 初始化 SDK Source: https://github.com/yidun/ntesquickpass/blob/master/doc/一键登录iOS SDK接入指南.md 在应用启动或页面加载时,使用业务 ID 初始化 SDK。 ```APIDOC ## [Method] registerWithBusinessID ### Description 初始化易盾一键登录 SDK。 ### Signature - (void)registerWithBusinessID:(NSString *)businessID; ### Parameters - **businessID** (NSString) - Required - 易盾分配的业务 ID ``` -------------------------------- ### 预取号 Source: https://github.com/yidun/ntesquickpass/blob/master/doc/一键登录iOS SDK接入指南.md 调用预取号接口获取临时凭证,为一键登录做准备。 ```APIDOC ## [Method] getPhoneNumberWithTotalInterval ### Description 移动、联通、电信预取号接口,需在初始化成功后调用。 ### Signature - (void)getPhoneNumberWithTotalInterval:(NSTimeInterval)totalInterval completion:(NTESQLGetPhoneNumHandler)phoneNumberHandler; ### Parameters - **totalInterval** (NSTimeInterval) - Optional - 预取号整体超时时间(毫秒),默认为 3000。 - **phoneNumberHandler** (NTESQLGetPhoneNumHandler) - Required - 预取号结果回调。 ### Callback Fields - **success** (BOOL) - 预取号是否成功 - **securityPhone** (NSString) - 脱敏手机号(电信返回,移动/联通不返回) - **resultCode** (NSString) - 运营商返回码 - **token** (NSString) - 易盾 token,有效期 2 分钟 - **desc** (NSString) - 结果描述信息 ``` -------------------------------- ### - (void)verifyPhoneNumber:businessID:configURL:extData:completion: Source: https://github.com/yidun/ntesquickpass/blob/master/doc/本机验证 iOS SDK接入指南.md 支持自定义 preCheck 接口 URL 和额外参数的验证方法。 ```APIDOC ## - (void)verifyPhoneNumber:(NSString *)phoneNumber businessID:(NSString *)businessID configURL:(NSString *)configURL extData:(NSString *)extData completion:(NTESQPCompletionHandler)completionHandler ### Description 支持配置私有化 URL 和额外参数的验证方法。 ### Parameters - **phoneNumber** (NSString) - 用户输入的手机号 - **businessID** (NSString) - 易盾分配的业务方 ID - **configURL** (NSString) - preCheck 接口的私有化 url - **extData** (NSString) - 额外参数 - **completionHandler** (NTESQPCompletionHandler) - 验证结果回调 ``` -------------------------------- ### - (NSString *)getSDKVersion Source: https://github.com/yidun/ntesquickpass/blob/master/doc/本机验证 iOS SDK接入指南.md 获取当前集成的 SDK 版本号。 ```APIDOC ## - (NSString *)getSDKVersion ### Description 获取当前 SDK 的版本号字符串。 ``` -------------------------------- ### NTESQuickLoginModel UI 配置 Source: https://github.com/yidun/ntesquickpass/blob/master/doc/一键登录iOS SDK接入指南.md 通过配置 NTESQuickLoginModel 对象来自定义登录页面的 UI 元素、隐私协议及事件回调。 ```APIDOC ## [Method] setupModel ### Description 将配置好的 UI 模型应用到 SDK 中。 ### Signature [[NTESQuickLoginManager sharedInstance] setupModel:model]; ### Configuration Properties - **logoImg/logoWidth/logoHeight** - 设置 Logo 图片及尺寸 - **logBtnText/logBtnTextColor** - 设置登录按钮文字及颜色 - **appPrivacyText/appFPrivacyURL** - 设置隐私协议文本及跳转链接 - **backActionBlock/loginActionBlock** - 设置返回及登录按钮点击回调 ``` -------------------------------- ### + (NTESQuickPassManager *)sharedInstance Source: https://github.com/yidun/ntesquickpass/blob/master/doc/本机验证 iOS SDK接入指南.md 获取 NTESQuickPassManager 的单例对象,用于后续调用 SDK 的各项功能。 ```APIDOC ## + (NTESQuickPassManager *)sharedInstance ### Description 获取 NTESQuickPassManager 的单例对象。 ### Return - **NTESQuickPassManager*** - 返回 SDK 管理器实例 ``` -------------------------------- ### Using MASCompositeConstraints for Edges Source: https://github.com/yidun/ntesquickpass/blob/master/Demo/NTESQuickPassPublicDemo/Pods/Masonry/README.md Shows how to constrain all edges of a view simultaneously, with optional insets. ```obj-c // make top, left, bottom, right equal view2 make.edges.equalTo(view2); // make top = superview.top + 5, left = superview.left + 10, // bottom = superview.bottom - 15, right = superview.right - 20 make.edges.equalTo(superview).insets(UIEdgeInsetsMake(5, 10, 15, 20)) ``` -------------------------------- ### 预取号接口定义 Source: https://github.com/yidun/ntesquickpass/blob/master/doc/一键登录iOS SDK接入指南.md 此接口支持自定义整体超时时间,需在初始化成功后调用。 ```objective-c /** * @abstract 移动、联通、电信 - 预取号接口,请确保在初始化成功后再调用此方法 * * @param totalInterval 预取号整体超时时间,单位ms,默认为 3000 * @param phoneNumberHandler 返回预取号结果 * */ - (void)getPhoneNumberWithTotalInterval:(NSTimeInterval)totalInterval completion:(NTESQLGetPhoneNumHandler)phoneNumberHandler; ``` -------------------------------- ### 获取当前上网卡的运营商 Source: https://github.com/yidun/ntesquickpass/blob/master/doc/一键登录iOS SDK接入指南.md 通过管理器获取当前设备上网卡的运营商类型。 ```objective-c NTESCarrierType carrierType = [self.manager getCarrier]; ``` -------------------------------- ### 隐私协议配置参数 Source: https://github.com/yidun/ntesquickpass/blob/master/doc/一键登录iOS SDK接入指南.md 用于设置隐私协议内容、链接及相关样式属性的配置项。 ```APIDOC ## 隐私协议配置参数 ### 协议内容配置 - **appPrivacyText** (string): 设置隐私的内容模板,必须包含“《默认》”字段。 - **appFPrivacyText/URL** (string): 第一个协议名称及链接。 - **appSPrivacyText/URL** (string): 第二个协议名称及链接。 - **appTPrivacyText/URL** (string): 第三个协议名称及链接。 - **appFourPrivacyText/URL** (string): 第四个协议名称及链接。 ### 样式配置 - **shouldHiddenPrivacyMarks** (boolean): 是否隐藏“《默认》”两边的《》,默认不隐藏。 - **privacyColor** (string): 隐私条款名称颜色。 - **privacyFont** (number): 隐私条款字体大小。 - **protocolColor** (string): 协议条款协议名称颜色。 - **appPrivacyLineSpacing** (number): 隐私协议行间距,默认 1。 - **appPrivacyWordSpacing** (number): 隐私协议字间距,默认 0。 - **progressColor** (string): 用户协议界面进度条颜色。 ``` -------------------------------- ### 运营商环境判断 Source: https://github.com/yidun/ntesquickpass/blob/master/doc/一键登录iOS SDK接入指南.md 在调用一键登录前,判断当前网络环境是否支持一键登录。 ```APIDOC ## [Method] shouldQuickLogin ### Description 判断当前上网卡的网络环境和运营商是否支持一键登录。 ### Signature - (BOOL)shouldQuickLogin; ### Returns - **BOOL** - 若返回 YES 则支持一键登录,否则建议走降级方案(如短信验证)。 ``` -------------------------------- ### Create shorthand edge constraints Source: https://github.com/yidun/ntesquickpass/blob/master/Demo/NTESQuickPassPublicDemo/Pods/Masonry/README.md A more concise way to define edge constraints using the edges property. ```obj-c [view1 mas_makeConstraints:^(MASConstraintMaker *make) { make.edges.equalTo(superview).with.insets(padding); }]; ``` -------------------------------- ### 获取单例对象 Source: https://github.com/yidun/ntesquickpass/blob/master/doc/本机验证 iOS SDK接入指南.md 获取 NTESQuickPassManager 单例。 ```objective-c /** * @abstract 单例 * * @return 返回NTESQuickPassManager对象 */ + (NTESQuickPassManager *)sharedInstance; ``` -------------------------------- ### 设置应用Logo图片 Source: https://github.com/yidun/ntesquickpass/blob/master/doc/一键登录iOS SDK接入指南.md 设置Logo图片的示例。 ```objective-c model.logoImg = [UIImage imageNamed:@"logo1"] ``` -------------------------------- ### - (void)verifyPhoneNumberWithBusinessID:configURL:extData:completion: Source: https://github.com/yidun/ntesquickpass/blob/master/doc/本机验证 iOS SDK接入指南.md 不通过手机号,仅通过业务 ID 和自定义配置获取 accessToken。 ```APIDOC ## - (void)verifyPhoneNumberWithBusinessID:(NSString *)businessID configURL:(NSString *)configURL extData:(NSString *)extData completion:(NTESQPCompletionHandler)completionHandler ### Description 不通过手机号进行验证的接口。 ### Parameters - **businessID** (NSString) - 易盾分配的业务方 ID - **configURL** (NSString) - preCheck 接口的私有化 url - **extData** (NSString) - 额外参数 - **completionHandler** (NTESQPCompletionHandler) - 验证结果回调 ``` -------------------------------- ### Chaining View Attributes Source: https://github.com/yidun/ntesquickpass/blob/master/Demo/NTESQuickPassPublicDemo/Pods/Masonry/README.md Demonstrates chaining multiple view attributes together for improved readability when defining constraints. ```obj-c // All edges but the top should equal those of the superview make.left.right.and.bottom.equalTo(superview); make.top.equalTo(otherView); ``` -------------------------------- ### 设置预取号超时时间 Source: https://github.com/yidun/ntesquickpass/blob/master/doc/一键登录iOS SDK接入指南.md 通过setTimeoutInterval设置运营商预取号和授权登录接口的超时时间,单位为毫秒。 ```objective-c [self.manager setTimeoutInterval:3000]; ``` -------------------------------- ### 设置导航返回图标 Source: https://github.com/yidun/ntesquickpass/blob/master/doc/一键登录iOS SDK接入指南.md 设置导航栏返回图标的示例。 ```objective-c navReturnImg = [UIImage imageNamed:@"back-1"] ``` -------------------------------- ### - (void)verifyPhoneNumber:businessID:completion: Source: https://github.com/yidun/ntesquickpass/blob/master/doc/本机验证 iOS SDK接入指南.md 通过用户输入的手机号和业务 ID 获取 accessToken,并返回验证结果。 ```APIDOC ## - (void)verifyPhoneNumber:(NSString *)phoneNumber businessID:(NSString *)businessID completion:(NTESQPCompletionHandler)completionHandler ### Description 发起本机验证请求,获取 accessToken。 ### Parameters - **phoneNumber** (NSString) - 用户输入的手机号 - **businessID** (NSString) - 易盾分配的业务方 ID - **completionHandler** (NTESQPCompletionHandler) - 验证结果回调 ``` -------------------------------- ### 设置导航栏自定义控件 Source: https://github.com/yidun/ntesquickpass/blob/master/doc/一键登录iOS SDK接入指南.md 通过customNavBlock在导航栏上自由添加自定义控件。 ```objective-c model.customNavBlock = ^(UIView * _Nullable customNavView) {/// 添加控件到customNavView上}; ``` -------------------------------- ### 授权页生命周期回调方法 Source: https://github.com/yidun/ntesquickpass/blob/master/doc/一键登录iOS SDK接入指南.md 定义了授权页在不同阶段的生命周期回调方法,用于监听授权页的加载、显示、消失及销毁过程。 ```objective-c /** * @说明 加载授权页。 */ - (void)authViewDidLoad /** * @说明 授权页将要出现。 */ - (void)authViewWillAppear /** * @说明 授权页已经出现。 */ - (void)authViewDidAppear /** * @说明 授权页将要消失。 */ - (void)authViewWillDisappear /** * @说明 授权页已经消失。 */ - (void)authViewDidDisappear /** * @说明 授权页销毁。 */ - (void)authViewDealloc ``` -------------------------------- ### 不通过手机号获取 accessToken Source: https://github.com/yidun/ntesquickpass/blob/master/doc/本机验证 iOS SDK接入指南.md 支持自定义配置 URL 和额外参数,但不传入手机号。 ```objective-c /** * @abstract 配置参数 - 不通过手机号 * * @param businessID 易盾分配的业务方ID * @param configURL preCheck接口的私有化url,若传nil或@"",默认使用@"https://ye.dun.163yun.com/v1/preCheck" * @param extData 当设置configURL时,可以增加额外参数,接入方自行处理 * @param completionHandler 返回验证结果,做下一步处理 * */ - (void)verifyPhoneNumberWithBusinessID:(NSString *)businessID configURL:(NSString * _Nullable)configURL extData:(NSString * _Nullable)extData completion:(NTESQPCompletionHandler _Nullable)completionHandler; ``` -------------------------------- ### 隐私弹窗样式配置 Source: https://github.com/yidun/ntesquickpass/blob/master/doc/一键登录iOS SDK接入指南.md 用于自定义隐私协议弹窗的尺寸、背景、标题、内容及按钮样式的配置项。 ```APIDOC ## 隐私弹窗样式配置 ### 弹窗基础属性 - **toastWidth/Height** (number): 弹窗宽高,默认 300x250。 - **toastBackgroundColor** (string): 弹窗背景颜色。 - **toastCornerRadius** (number): 弹窗圆角,默认 8。 ### 标题与内容 - **toastTitleText** (string): 弹窗标题文本。 - **toastTitleTextColor/FontSize/FontWeight** (string/number): 标题样式设置。 - **toastContentPrefixText/SuffixText** (string): 内容前缀与后缀文本。 - **toastContentTextColor/FontSize/FontWeight** (string/number): 内容文本样式设置。 ### 按钮配置 - **toastCancelWidth/Height/Text/TextColor** (number/string): 取消按钮样式设置。 - **toastConfirmWidth/Height/Text/TextColor** (number/string): 确定按钮样式设置。 ``` -------------------------------- ### 定义 NTESQPCompletionHandler 回调 Source: https://github.com/yidun/ntesquickpass/blob/master/doc/本机验证 iOS SDK接入指南.md 定义获取 accessToken 结果的回调 block。 ```objective-c /** * @abstract block * * @说明 获取accessToken结果的回调 */ typedef void(^NTESQPCompletionHandler)(NSDictionary *params, NTESQPStatus status, BOOL success); ``` -------------------------------- ### CUCMCTAuthorizeLoginCompletion 授权登录 Source: https://github.com/yidun/ntesquickpass/blob/master/doc/一键登录iOS SDK接入指南.md 在预取号成功后,调用此方法进行授权登录并获取 accessToken。 ```APIDOC ## [Method] CUCMCTAuthorizeLoginCompletion ### Description 发起授权登录请求,获取 accessToken 用于服务端校验。 ### Signature [[NTESQuickLoginManager sharedInstance] CUCMCTAuthorizeLoginCompletion:^(NSDictionary * _Nonnull resultDic) { ... }]; ### Parameters - **resultDic** (NSDictionary) - 包含 success (BOOL) 和 accessToken (NSString) 的结果字典。 ``` -------------------------------- ### clearPreLoginCache Source: https://github.com/yidun/ntesquickpass/blob/master/doc/一键登录iOS SDK接入指南.md 清除预取号缓存。 ```APIDOC ## [Method] clearPreLoginCache ### Description 清除本地缓存的预取号信息。 ``` -------------------------------- ### 定义 NTESQPStatus 枚举 Source: https://github.com/yidun/ntesquickpass/blob/master/doc/本机验证 iOS SDK接入指南.md 定义获取 accessToken 的状态枚举。 ```objective-c /** * @abstract 获取accessToken的状态 * * @说明 NTESQPCompletionHandler对象的参数,用于表示获取accessToken的状态 * NTESQPPhoneNumInvalid表示手机号不合法 * NTESQPNonGateway表示当前网络环境不可网关验证 * NTESQPAccessTokenSuccess获取accessToken成功 * NTESQPAccessTokenFailure获取accessToken失败 * NTESQPAccessTokenTimeout获取accessToken超时 * */ typedef NS_ENUM(NSInteger, NTESQPStatus) { NTESQPPhoneNumInvalid = 1, NTESQPNonGateway, NTESQPAccessTokenSuccess, NTESQPAccessTokenFailure, NTESQPAccessTokenTimeout, }; ``` -------------------------------- ### 自定义配置获取 accessToken Source: https://github.com/yidun/ntesquickpass/blob/master/doc/本机验证 iOS SDK接入指南.md 支持自定义 preCheck 接口 URL 和额外参数。 ```objective-c /** * @abstract 配置参数 * * @param phoneNumber 用户输入的手机号 * @param businessID 易盾分配的业务方ID * @param configURL preCheck接口的私有化url,若传nil或@"",默认使用@"https://ye.dun.163yun.com/v1/preCheck" * @param extData 当设置configURL时,可以增加额外参数,接入方自行处理 * @param completionHandler 返回验证结果,做下一步处理 * */ - (void)verifyPhoneNumber:(NSString *)phoneNumber businessID:(NSString *)businessID configURL:(NSString * _Nullable)configURL extData:(NSString * _Nullable)extData completion:(NTESQPCompletionHandler _Nullable)completionHandler; ``` -------------------------------- ### 获取 accessToken 接口 Source: https://github.com/yidun/ntesquickpass/blob/master/doc/本机验证 iOS SDK接入指南.md 通过手机号和业务 ID 获取 accessToken。 ```objective-c /** * @abstract 配置参数 * * @param phoneNumber 用户输入的手机号 * @param businessID 易盾分配的业务方ID * @param completionHandler 返回验证结果,做下一步处理 * */ - (void)verifyPhoneNumber:(NSString *)phoneNumber businessID:(NSString *)businessID completion:(NTESQPCompletionHandler)completionHandler; - ``` -------------------------------- ### Constraint with UIView/NSView Source: https://github.com/yidun/ntesquickpass/blob/master/Demo/NTESQuickPassPublicDemo/Pods/Masonry/README.md Shows that passing a view is equivalent to passing its attribute. ```obj-c //these two constraints are exactly the same make.left.greaterThanOrEqualTo(label); make.left.greaterThanOrEqualTo(label.mas_left); ``` -------------------------------- ### getCarrier Source: https://github.com/yidun/ntesquickpass/blob/master/doc/一键登录iOS SDK接入指南.md 获取当前上网卡的运营商类型。 ```APIDOC ## [Method] getCarrier ### Description 获取当前设备上网卡的运营商信息。 ### Returns - **NTESCarrierType** (enum) - 返回值包括:NTESCarrierTypeUnknown(未知), NTESCarrierTypeTelecom(电信), NTESCarrierTypeMobile(移动), NTESCarrierTypeUnicom(联通) ``` -------------------------------- ### 调用 verifyPhoneNumber 接口 Source: https://github.com/yidun/ntesquickpass/blob/master/doc/本机验证 iOS SDK接入指南.md 在需要获取 accessToken 的地方调用验证接口,并处理成功或失败的回调。 ```objective-c [self.manager verifyPhoneNumber:self.phoneNumTextField.text businessID:BUSINESSID completion:^(NSDictionary * _Nullable params, NTESQPStatus status, BOOL success) { if (success) { // 获取accessToken成功回调 } else { // 获取accessToken失败回调 }]; ``` -------------------------------- ### 清除预取号缓存 Source: https://github.com/yidun/ntesquickpass/blob/master/doc/一键登录iOS SDK接入指南.md 清除SDK内部存储的预取号缓存数据。 ```objective-c [self.manager clearPreLoginCache]; ``` -------------------------------- ### Constraint with primitives and structs Source: https://github.com/yidun/ntesquickpass/blob/master/Demo/NTESQuickPassPublicDemo/Pods/Masonry/README.md Using mas_ prefixed macros for autoboxing primitives and structs. ```obj-c make.top.mas_equalTo(42); make.height.mas_equalTo(20); make.size.mas_equalTo(CGSizeMake(50, 100)); make.edges.mas_equalTo(UIEdgeInsetsMake(10, 0, 10, 0)); make.left.mas_equalTo(view).mas_offset(UIEdgeInsetsMake(10, 0, 10, 0)); ```