iOS SDK API
最近更新:2022-11-15
展开全部

iOS SDK API

SDK 接口说明

  • JVERIFICATIONService,包含 SDK 所有接口
  • JVAuthConfig 类,应用配置信息类
  • JVLayoutConstraint 类, 认证界面控件布局类
  • JVLayoutItem, 布局参照枚举
  • JVUIConfig 类,登录界面 UI 配置基类
    • JVMobileUIConfig 类,移动登录界面 UI 配置类,JVUIConfig 的子类
    • JVUnicomUIConfig 类,联通登录界面 UI 配置类,JVUIConfig 的子类
    • VTelecomUIConfig 类,电信登录界面 UI 配置类,JVUIConfig 的子类

设置 Debug 模式

支持的版本

开始支持的版本 1.0.0

接口定义

  • + (void)setDebug:(BOOL)enable;
    • 接口说明:
      • 开启 debug 模式
    • 参数说明
      • enable 是否开启 debug 模式

SDK 初始化

支持回调参数

支持的版本

开始支持的版本 2.3.6

接口定义

  • + setupWithConfig:(JVAuthConfig *)config;

    • 接口说明:
      • 初始化接口
    • 参数说明
      • config 配置类
    • 调用示例:
OC // 如需使用 IDFA 功能请添加此代码并在初始化配置类中设置 advertisingId NSString *idfaStr = [[[ASIdentifierManager sharedManager] advertisingIdentifier] UUIDString]; JVAuthConfig *config = [[JVAuthConfig alloc] init]; config.appKey = @"AppKey copied from JiGuang Portal application"; config.advertisingId = idfaStr; config.authBlock = ^(NSDictionary *result) {NSLog(@"初始化结果 result:%@", result); }; [JVERIFICATIONService setupWithConfig:config]; Swift let adString = ASIdentifierManager.shared().advertisingIdentifier.uuidString let config = JVAuthConfig() config.appKey = "a0e6ace8d5b3e0247e3f58db" config.authBlock = {(result) -> Void in if let result = result {if let code = result["code"], let content = result["content"] {print("初始化结果 result: code = \(code), content = \(content)")}} } JVERIFICATIONService.setup(with: config)
          OC
    // 如需使用 IDFA 功能请添加此代码并在初始化配置类中设置 advertisingId
    NSString *idfaStr = [[[ASIdentifierManager sharedManager] advertisingIdentifier] UUIDString];
    
    JVAuthConfig *config = [[JVAuthConfig alloc] init];
    config.appKey = @"AppKey copied from JiGuang Portal application";
    config.advertisingId = idfaStr;
    config.authBlock = ^(NSDictionary *result) {NSLog(@"初始化结果 result:%@", result);
    };
    [JVERIFICATIONService setupWithConfig:config];
    
Swift
    let adString = ASIdentifierManager.shared().advertisingIdentifier.uuidString
    let config = JVAuthConfig()
    config.appKey = "a0e6ace8d5b3e0247e3f58db"
    config.authBlock = {(result) -> Void in
            if let result = result {if let code = result["code"], let content = result["content"] {print("初始化结果 result: code = \(code), content = \(content)")}}
        }
    JVERIFICATIONService.setup(with: config)    
    

        
此代码块在浮窗中显示

不带回调参数

支持的版本

开始支持的版本 1.0.0

接口定义

  • + setupWithConfig:(JVAuthConfig *)config;

    • 接口说明:
      • 初始化接口
    • 参数说明
      • config 配置类
    • 调用示例:
// 如需使用 IDFA 功能请添加此代码并在初始化配置类中设置 advertisingId NSString *idfaStr = [[[ASIdentifierManager sharedManager] advertisingIdentifier] UUIDString]; JVAuthConfig *config = [[JVAuthConfig alloc] init]; config.appKey = @"a0e6ace8d5b3e0247e3f58db"; config.advertisingId = idfaStr; [JVERIFICATIONService setupWithConfig:config];
              // 如需使用 IDFA 功能请添加此代码并在初始化配置类中设置 advertisingId
    NSString *idfaStr = [[[ASIdentifierManager sharedManager] advertisingIdentifier] UUIDString];
    
    JVAuthConfig *config = [[JVAuthConfig alloc] init];
    config.appKey = @"a0e6ace8d5b3e0247e3f58db";
    config.advertisingId = idfaStr;
    [JVERIFICATIONService setupWithConfig:config];

        
此代码块在浮窗中显示

获取 SDK 初始化状态

支持的版本

开始支持的版本 2.3.2

接口定义

  • + (BOOL)isSetupClient

    • 接口说明:
      • 初始化是否成功
    • 返回值说明
      • YES 初始化成功
      • NO 初始化失败
    • 调用示例:
OC BOOL isSetupClient = [JVERIFICATIONService isSetupClient]; if (isSetupClient) {// 初始化完成,可以进行后续操作} Swift let isSetup = JVERIFICATIONService.isSetupClient() if isSetup {// 初始化完成,可以进行后续操作}
          OC
    BOOL isSetupClient = [JVERIFICATIONService isSetupClient];
    if (isSetupClient) {// 初始化完成,可以进行后续操作}

Swift
    let isSetup =  JVERIFICATIONService.isSetupClient()
    if isSetup {// 初始化完成,可以进行后续操作}

        
此代码块在浮窗中显示

判断网络环境是否支持

支持的版本

开始支持的版本 1.1.2

接口定义

  • + (BOOL)checkVerifyEnable;
    • 接口说明:

      • 判断当前网络环境是否可以发起认证
    • 返回值说明

      • YES 可以认证
      • NO 不可以认证
    • 调用示例:

OC if(![JVERIFICATIONService checkVerifyEnable]) {NSLog(@"当前网络环境不支持认证!"); return; } // 继续获取 token 操作 ... Swift if !JVERIFICATIONService.checkVerifyEnable() {print("当前网络环境不支持认证!") return } // 继续获取 token 操作 ...
          OC
    if(![JVERIFICATIONService checkVerifyEnable]) {NSLog(@"当前网络环境不支持认证!");
        return;
    }
    // 继续获取 token 操作
    ...
Swift
      if !JVERIFICATIONService.checkVerifyEnable() {print("当前网络环境不支持认证!")
        return
    }
    // 继续获取 token 操作
    ...

        
此代码块在浮窗中显示

一键登录

初始化

调用 SDK 其他流程方法前,请确保已调用过初始化,否则会返回未初始化,详情参考 SDK 初始化 API(会采集信息,建议放到同意协议后调用)。

判断网络环境是否支持

判断当前的手机网络环境是否可以使用一键登录,若网络支持,再调用一键登录 API,否则请调用其他登录方式的 API,详情参考 判断网络环境是否支持 API

预取号

支持的版本

开始支持的版本 2.2.0

接口定义

  • + (void)preLogin:(NSTimeInterval)timeout completion:(void (^)(NSDictionary *result))completion

    • 接口说明:

      • 验证当前运营商网络是否可以进行一键登录操作,该方法会缓存取号信息,提高一键登录效率。建议发起一键登录前先调用此方法。
    • 参数说明:

      • completion 预取号结果
      • result 字典 key 为 code 和 message 两个字段
      • timeout 超时时间(毫秒), 有效取值范围(0,10000]. 为保证获取 token 的成功率,建议设置为 3000-5000ms.
    • 调用示例:

OC [JVERIFICATIONService preLogin:5000 completion:^(NSDictionary *result) {NSLog(@"登录预取号 result:%@", result); }]; Swift JVERIFICATIONService.preLogin(5000) {(result) in if let result = result {if let code = result["code"], let message = result["message"] {print("preLogin result: code = \(code), message = \(message)")}} }
          OC
    [JVERIFICATIONService preLogin:5000 completion:^(NSDictionary *result) {NSLog(@"登录预取号 result:%@", result);
    }];
    
Swift 
     JVERIFICATIONService.preLogin(5000) {(result) in
          if let result = result {if let code = result["code"], let message = result["message"] {print("preLogin result: code = \(code), message = \(message)")}}
      }   
    

        
此代码块在浮窗中显示

清除预取号缓存

  • + (BOOL)clearPreLoginCache;
    • 接口说明:

      • 清除预取号缓存
    • 调用示例:

OC [JVERIFICATIONService clearPreLoginCache]; Swift JVERIFICATIONService.clearPreLoginCache()
          OC
   [JVERIFICATIONService clearPreLoginCache]; 
   
Swift
    JVERIFICATIONService.clearPreLoginCache()   

        
此代码块在浮窗中显示

拉起授权页面(新)

支持的版本

开始支持的版本 2.5.2

接口定义

  • + (void)getAuthorizationWithController:(UIViewController *)vc hide:(BOOL)hide animated:(BOOL)animationFlag timeout:(NSTimeInterval)timeoutcompletion:(void (^)(NSDictionary *result))completion actionBlock:(void(^)(NSInteger type, NSString *content))actionBlock

    • 接口说明:

      • 授权登录
    • 参数说明:

      • completion 登录结果
      • result 字典 获取到 token 时 key 有 operator、code、loginToken 字段,获取不到 token 是 key 为 code 和 content 字段
      • vc 当前控制器
      • hide 完成后是否自动隐藏授权页。
      • animationFlag 拉起授权页时是否需要动画效果,默认 YES
      • timeout 超时。单位毫秒,合法范围是(0,30000],默认值为 10000。此参数同时作用于拉起授权页超时,以及点击授权页登录按钮获取 LoginToken 超时
      • actionBlock 授权页事件触发回调。包含 type 和 content 两个参数,type 为事件类型,content 为事件描述。 type = 1, 授权页被关闭;type=2, 授权页面被拉起;type=3, 运营商协议被点击;type=4, 自定义协议 1 被点击;type=5, 自定义协议 2 被点击;type=6,checkBox 变为选中;type=7,checkBox 变为未选中;type=8, 登录按钮被点击
    • 调用示例:

OC [JVERIFICATIONService getAuthorizationWithController:self hide:NO animated:YES timeout:5*1000 completion:^(NSDictionary *result) {NSLog(@"一键登录 result:%@", result); } actionBlock:^(NSInteger type, NSString *content) {NSLog(@"一键登录 actionBlock :%ld %@", (long)type , content);}]; Swift JVERIFICATIONService.getAuthorizationWith(self, hide: true, animated: true, timeout: 5*1000, completion: { (result) in if let result = result {if let token = result["loginToken"] {if let code = result["code"], let op = result["operator"] {print("一键登录 result: code = \(code), operator = \(op), loginToken = \(token)")}}else if let code = result["code"], let content = result["content"] {print("一键登录 result: code = \(code), content = \(content)")}} }){ (type, content) in if let content = content {print("一键登录 actionBlock :type = \(type), content = \(content)")}}
          OC
    [JVERIFICATIONService getAuthorizationWithController:self hide:NO animated:YES timeout:5*1000 completion:^(NSDictionary *result) {NSLog(@"一键登录 result:%@", result);
    } actionBlock:^(NSInteger type, NSString *content) {NSLog(@"一键登录 actionBlock :%ld %@", (long)type , content);}];
    
Swift 
     JVERIFICATIONService.getAuthorizationWith(self, hide: true, animated: true, timeout: 5*1000, completion: { (result) in
        if let result = result {if let token = result["loginToken"] {if let code = result["code"], let op = result["operator"] {print("一键登录 result: code = \(code), operator = \(op), loginToken = \(token)")}}else if let code = result["code"], let content = result["content"] {print("一键登录 result: code = \(code), content = \(content)")}}
    }){ (type, content) in
        if let content = content {print("一键登录 actionBlock :type = \(type), content = \(content)")}}
  

        
此代码块在浮窗中显示

说明:获取到一键登录的 loginToken 后,将其返回给应用服务端,从服务端调用 REST API 来获取手机号码。

关闭授权页面

支持的版本

开始支持的版本 2.5.2

接口定义

  • + (void)dismissLoginControllerAnimated: (BOOL)flag completion: (void (^)(void))completion;

    • 接口说明:
      • 隐藏登录页. 当授权页被拉起以后,可调用此接口隐藏授权页。当一键登录自动隐藏授权页时,不建议调用此接口
    • 参数说明:
      • flag 隐藏时是否需要动画
      • completion 字典授权页隐藏完成后回调
    • 调用示例:
OC [JVERIFICATIONService dismissLoginControllerAnimated:YES completion:^{// 授权页隐藏完成}]; Swift JVERIFICATIONService.dismissLoginController(animated: true) {// 授权页隐藏完成}
          OC
    [JVERIFICATIONService dismissLoginControllerAnimated:YES completion:^{// 授权页隐藏完成}];
    
Swift    
    JVERIFICATIONService.dismissLoginController(animated: true) {// 授权页隐藏完成}

        
此代码块在浮窗中显示

支持的版本

开始支持的版本:2.3.0

接口定义

  • + (void)dismissLoginController;

    • 接口说明:

      • 关闭授权页,从 2.5.2 版本开始,此接口已废弃
    • 调用示例:

[JVERIFICATIONService dismissLoginController];
              [JVERIFICATIONService dismissLoginController];

        
此代码块在浮窗中显示

自定义授权页面 UI 样式

开发者不得通过任何技术手段将授权页面的隐私协议栏、slogan 隐藏或者覆盖,对于接入极光认证 SDK 并上线的应用,我方会对上线的应用授权页面做审查,如果发现未按要求设计授权页面,将关闭应用的一键登录服务。

支持的版本

开始支持的版本 2.0.0

接口定义

  • + (void)customUIWithConfig:(JVUIConfig *)UIConfig;

    • 接口说明:
      • 自定义登录页 UI 样式
    • 参数说明:
      • UIConfig JVUIConfig 对象
JVUIConfig *config = [[JVUIConfig alloc] init]; config.navCustom = NO; // config.prefersStatusBarHidden = YES; config.shouldAutorotate = YES; config.autoLayout = YES; // config.orientation = UIInterfaceOrientationPortrait; config.navReturnHidden = NO; config.privacyTextFontSize = 12; config.navText = [[NSAttributedString alloc]initWithString:@"登录统一认证" attributes:@{NSForegroundColorAttributeName:[UIColor whiteColor], NSFontAttributeName:[UIFont systemFontOfSize:18]}]; // config.navColor = [UIColor redColor]; // config.navBarBackGroundImage = [UIImage imageNamed:@"cmccLogo"]; config.privacyTextAlignment = NSTextAlignmentLeft; // config.numberFont = [UIFont systemFontOfSize:10]; // config.logBtnFont = [UIFont systemFontOfSize:5]; // config.privacyShowBookSymbol = YES; // config.privacyLineSpacing = 5; // config.agreementNavBackgroundColor = [UIColor redColor]; // config.sloganFont = [UIFont systemFontOfSize:30]; // config.checkViewHidden = YES; config.modalTransitionStyle = UIModalTransitionStyleCoverVertical; /* config.customLoadingViewBlock = ^(UIView *View) {MBProgressHUD *hub = [MBProgressHUD showHUDAddedTo:View animated:YES]; hub.backgroundColor = [UIColor clearColor]; hub.label.text = @"正在登录.."; [hub showAnimated:YES]; }; */ /* config.customPrivacyAlertViewBlock = ^(UIViewController *vc) {UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"请点击同意协议" message:nil preferredStyle:UIAlertControllerStyleAlert]; [alert addAction:[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:nil]]; [vc presentViewController:alert animated:true completion:nil]; }; */ //logo config.logoImg = [UIImage imageNamed:@"cmccLogo"]; CGFloat logoWidth = config.logoImg.size.width?:100; CGFloat logoHeight = logoWidth; JVLayoutConstraint *logoConstraintX = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeCenterX relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemSuper attribute:NSLayoutAttributeCenterX multiplier:1 constant:0]; JVLayoutConstraint *logoConstraintY = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemSuper attribute:NSLayoutAttributeCenterY multiplier:1 constant:-90]; JVLayoutConstraint *logoConstraintW = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemNone attribute:NSLayoutAttributeWidth multiplier:1 constant:logoWidth]; JVLayoutConstraint *logoConstraintH = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemNone attribute:NSLayoutAttributeHeight multiplier:1 constant:logoHeight]; config.logoConstraints = @[logoConstraintX,logoConstraintY,logoConstraintW,logoConstraintH]; config.logoHorizontalConstraints = config.logoConstraints; // 号码栏 JVLayoutConstraint *numberConstraintX = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeCenterX relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemSuper attribute:NSLayoutAttributeCenterX multiplier:1 constant:0]; JVLayoutConstraint *numberConstraintY = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeCenterY relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemSuper attribute:NSLayoutAttributeCenterY multiplier:1 constant:-55]; JVLayoutConstraint *numberConstraintW = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemNone attribute:NSLayoutAttributeWidth multiplier:1 constant:130]; JVLayoutConstraint *numberConstraintH = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemNone attribute:NSLayoutAttributeHeight multiplier:1 constant:25]; config.numberConstraints = @[numberConstraintX,numberConstraintY, numberConstraintW, numberConstraintH]; config.numberHorizontalConstraints = config.numberConstraints; //slogan 展示 JVLayoutConstraint *sloganConstraintX = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeCenterX relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemSuper attribute:NSLayoutAttributeCenterX multiplier:1 constant:0]; JVLayoutConstraint *sloganConstraintY = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemSuper attribute:NSLayoutAttributeCenterY multiplier:1 constant:-20]; JVLayoutConstraint *sloganConstraintW = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemNone attribute:NSLayoutAttributeWidth multiplier:1 constant:130]; JVLayoutConstraint *sloganConstraintH = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemNone attribute:NSLayoutAttributeHeight multiplier:1 constant:20]; config.sloganConstraints = @[sloganConstraintX,sloganConstraintY, sloganConstraintW, sloganConstraintH]; config.sloganHorizontalConstraints = config.sloganConstraints; // 登录按钮 UIImage *login_nor_image = [self imageNamed:@"loginBtn_Nor"]; UIImage *login_dis_image = [self imageNamed:@"loginBtn_Dis"]; UIImage *login_hig_image = [self imageNamed:@"loginBtn_Hig"]; if (login_nor_image && login_dis_image && login_hig_image) {config.logBtnImgs = @[login_nor_image, login_dis_image, login_hig_image]; } CGFloat loginButtonWidth = login_nor_image.size.width?:100; CGFloat loginButtonHeight = login_nor_image.size.height?:100; JVLayoutConstraint *loginConstraintX = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeCenterX relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemSuper attribute:NSLayoutAttributeCenterX multiplier:1 constant:0]; JVLayoutConstraint *loginConstraintY = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemSuper attribute:NSLayoutAttributeCenterY multiplier:1 constant:30]; JVLayoutConstraint *loginConstraintW = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemNone attribute:NSLayoutAttributeWidth multiplier:1 constant:loginButtonWidth]; JVLayoutConstraint *loginConstraintH = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemNone attribute:NSLayoutAttributeHeight multiplier:1 constant:loginButtonHeight]; config.logBtnConstraints = @[loginConstraintX,loginConstraintY,loginConstraintW,loginConstraintH]; config.logBtnHorizontalConstraints = config.logBtnConstraints; // 勾选框 UIImage * uncheckedImg = [self imageNamed:@"checkBox_unSelected"]; UIImage * checkedImg = [self imageNamed:@"checkBox_selected"]; CGFloat checkViewWidth = uncheckedImg.size.width; CGFloat checkViewHeight = uncheckedImg.size.height; config.uncheckedImg = uncheckedImg; config.checkedImg = checkedImg; JVLayoutConstraint *checkViewConstraintX = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemSuper attribute:NSLayoutAttributeLeft multiplier:1 constant:20]; JVLayoutConstraint *checkViewConstraintY = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeCenterY relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemPrivacy attribute:NSLayoutAttributeCenterY multiplier:1 constant:0]; JVLayoutConstraint *checkViewConstraintW = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemNone attribute:NSLayoutAttributeWidth multiplier:1 constant:checkViewWidth]; JVLayoutConstraint *checkViewConstraintH = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemNone attribute:NSLayoutAttributeHeight multiplier:1 constant:checkViewHeight]; config.checkViewConstraints = @[checkViewConstraintX,checkViewConstraintY,checkViewConstraintW,checkViewConstraintH]; config.checkViewHorizontalConstraints = config.checkViewConstraints; // 隐私 CGFloat spacing = checkViewWidth + 20 + 5; config.privacyState = YES; JVLayoutConstraint *privacyConstraintX = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemSuper attribute:NSLayoutAttributeLeft multiplier:1 constant:spacing]; JVLayoutConstraint *privacyConstraintX2 = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemSuper attribute:NSLayoutAttributeRight multiplier:1 constant:-spacing]; JVLayoutConstraint *privacyConstraintY = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemSuper attribute:NSLayoutAttributeBottom multiplier:1 constant:-10]; JVLayoutConstraint *privacyConstraintH = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemNone attribute:NSLayoutAttributeHeight multiplier:1 constant:50]; config.privacyConstraints = @[privacyConstraintX,privacyConstraintX2,privacyConstraintY,privacyConstraintH]; config.privacyHorizontalConstraints = config.privacyConstraints; //loading JVLayoutConstraint *loadingConstraintX = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeCenterX relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemSuper attribute:NSLayoutAttributeCenterX multiplier:1 constant:0]; JVLayoutConstraint *loadingConstraintY = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeCenterY relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemSuper attribute:NSLayoutAttributeCenterY multiplier:1 constant:0]; JVLayoutConstraint *loadingConstraintW = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemNone attribute:NSLayoutAttributeWidth multiplier:1 constant:30]; JVLayoutConstraint *loadingConstraintH = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemNone attribute:NSLayoutAttributeHeight multiplier:1 constant:30]; config.loadingConstraints = @[loadingConstraintX,loadingConstraintY,loadingConstraintW,loadingConstraintH]; config.loadingHorizontalConstraints = config.loadingConstraints; /* config.authPageBackgroundImage = [UIImage imageNamed:@"背景图"]; config.navColor = [UIColor redColor]; config.preferredStatusBarStyle = 0; config.navText = [[NSAttributedString alloc] initWithString:@"自定义标题"]; config.navReturnImg = [UIImage imageNamed:@"自定义返回键"]; UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom]; button.frame = CGRectMake(0, 0, 44, 44); button.backgroundColor = [UIColor greenColor]; config.navControl = [[UIBarButtonItem alloc] initWithCustomView:button]; config.logoHidden = NO; config.logBtnText = @"自定义登录按钮文字"; config.logBtnTextColor = [UIColor redColor]; config.numberColor = [UIColor blueColor]; config.appPrivacyOne = @[@"应用自定义服务条款 1",@"https://www.jiguang.cn/about"]; config.appPrivacyTwo = @[@"应用自定义服务条款 2",@"https://www.jiguang.cn/about"]; config.privacyComponents = @[@"文本 1",@"文本 2",@"文本 3",@"文本 4"]; config.appPrivacyColor = @[[UIColor redColor], [UIColor blueColor]]; config.sloganTextColor = [UIColor redColor]; config.navCustom = NO; config.numberSize = 24; config.privacyState = YES; */ [JVERIFICATIONService customUIWithConfig:config];
              JVUIConfig *config = [[JVUIConfig alloc] init];
    config.navCustom = NO;
//    config.prefersStatusBarHidden = YES;
    config.shouldAutorotate = YES;
    config.autoLayout = YES;
//    config.orientation =  UIInterfaceOrientationPortrait;
    
    config.navReturnHidden = NO;
    config.privacyTextFontSize = 12;
    config.navText = [[NSAttributedString alloc]initWithString:@"登录统一认证" attributes:@{NSForegroundColorAttributeName:[UIColor whiteColor], NSFontAttributeName:[UIFont systemFontOfSize:18]}];
//    config.navColor = [UIColor redColor];
//    config.navBarBackGroundImage = [UIImage imageNamed:@"cmccLogo"];
    config.privacyTextAlignment = NSTextAlignmentLeft;
//    config.numberFont = [UIFont systemFontOfSize:10];
//    config.logBtnFont = [UIFont systemFontOfSize:5];
//    config.privacyShowBookSymbol = YES;
//    config.privacyLineSpacing = 5;
//    config.agreementNavBackgroundColor = [UIColor redColor];
//    config.sloganFont = [UIFont systemFontOfSize:30];
//    config.checkViewHidden = YES;
    config.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
    
    /*
    config.customLoadingViewBlock = ^(UIView *View) {MBProgressHUD *hub = [MBProgressHUD showHUDAddedTo:View animated:YES];
        hub.backgroundColor = [UIColor clearColor];
        hub.label.text = @"正在登录..";
        [hub showAnimated:YES];
    };
    */
    
    /*
    config.customPrivacyAlertViewBlock = ^(UIViewController *vc) {UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"请点击同意协议" message:nil preferredStyle:UIAlertControllerStyleAlert];
        [alert addAction:[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:nil]];
        [vc presentViewController:alert animated:true completion:nil];
    };
    */
     
    
    //logo
    config.logoImg = [UIImage imageNamed:@"cmccLogo"];
    CGFloat logoWidth = config.logoImg.size.width?:100;
    CGFloat logoHeight = logoWidth;
    JVLayoutConstraint *logoConstraintX = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeCenterX relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemSuper attribute:NSLayoutAttributeCenterX multiplier:1 constant:0];
    JVLayoutConstraint *logoConstraintY = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemSuper attribute:NSLayoutAttributeCenterY multiplier:1 constant:-90];
    JVLayoutConstraint *logoConstraintW = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemNone attribute:NSLayoutAttributeWidth multiplier:1 constant:logoWidth];
    JVLayoutConstraint *logoConstraintH = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemNone attribute:NSLayoutAttributeHeight multiplier:1 constant:logoHeight];
    config.logoConstraints = @[logoConstraintX,logoConstraintY,logoConstraintW,logoConstraintH];
    config.logoHorizontalConstraints = config.logoConstraints;

    
    
    // 号码栏
    JVLayoutConstraint *numberConstraintX = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeCenterX relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemSuper attribute:NSLayoutAttributeCenterX multiplier:1 constant:0];
    JVLayoutConstraint *numberConstraintY = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeCenterY relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemSuper attribute:NSLayoutAttributeCenterY multiplier:1 constant:-55];
    JVLayoutConstraint *numberConstraintW = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemNone attribute:NSLayoutAttributeWidth multiplier:1 constant:130];
    JVLayoutConstraint *numberConstraintH = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemNone attribute:NSLayoutAttributeHeight multiplier:1 constant:25];
    config.numberConstraints = @[numberConstraintX,numberConstraintY, numberConstraintW, numberConstraintH];
    config.numberHorizontalConstraints = config.numberConstraints;
    
    //slogan 展示
    JVLayoutConstraint *sloganConstraintX = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeCenterX relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemSuper attribute:NSLayoutAttributeCenterX multiplier:1 constant:0];
    JVLayoutConstraint *sloganConstraintY = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemSuper attribute:NSLayoutAttributeCenterY multiplier:1 constant:-20];
    JVLayoutConstraint *sloganConstraintW = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemNone attribute:NSLayoutAttributeWidth multiplier:1 constant:130];
    JVLayoutConstraint *sloganConstraintH = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemNone attribute:NSLayoutAttributeHeight multiplier:1 constant:20];
    config.sloganConstraints = @[sloganConstraintX,sloganConstraintY, sloganConstraintW, sloganConstraintH];
    config.sloganHorizontalConstraints = config.sloganConstraints;
    
    
    // 登录按钮
    UIImage *login_nor_image = [self imageNamed:@"loginBtn_Nor"];
    UIImage *login_dis_image = [self imageNamed:@"loginBtn_Dis"];
    UIImage *login_hig_image = [self imageNamed:@"loginBtn_Hig"];
    if (login_nor_image && login_dis_image && login_hig_image) {config.logBtnImgs = @[login_nor_image, login_dis_image, login_hig_image];
    }
    CGFloat loginButtonWidth = login_nor_image.size.width?:100;
    CGFloat loginButtonHeight = login_nor_image.size.height?:100;
    JVLayoutConstraint *loginConstraintX = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeCenterX relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemSuper attribute:NSLayoutAttributeCenterX multiplier:1 constant:0];
    JVLayoutConstraint *loginConstraintY = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemSuper attribute:NSLayoutAttributeCenterY multiplier:1 constant:30];
    JVLayoutConstraint *loginConstraintW = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemNone attribute:NSLayoutAttributeWidth multiplier:1 constant:loginButtonWidth];
    JVLayoutConstraint *loginConstraintH = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemNone attribute:NSLayoutAttributeHeight multiplier:1 constant:loginButtonHeight];
    config.logBtnConstraints = @[loginConstraintX,loginConstraintY,loginConstraintW,loginConstraintH];
    config.logBtnHorizontalConstraints = config.logBtnConstraints;
    
    // 勾选框
    UIImage * uncheckedImg = [self imageNamed:@"checkBox_unSelected"];
    UIImage * checkedImg = [self imageNamed:@"checkBox_selected"];
    CGFloat checkViewWidth = uncheckedImg.size.width;
    CGFloat checkViewHeight = uncheckedImg.size.height;
    config.uncheckedImg = uncheckedImg;
    config.checkedImg = checkedImg;
    JVLayoutConstraint *checkViewConstraintX = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemSuper attribute:NSLayoutAttributeLeft multiplier:1 constant:20];
    JVLayoutConstraint *checkViewConstraintY = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeCenterY relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemPrivacy attribute:NSLayoutAttributeCenterY multiplier:1 constant:0];
    JVLayoutConstraint *checkViewConstraintW = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemNone attribute:NSLayoutAttributeWidth multiplier:1 constant:checkViewWidth];
    JVLayoutConstraint *checkViewConstraintH = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemNone attribute:NSLayoutAttributeHeight multiplier:1 constant:checkViewHeight];
    config.checkViewConstraints = @[checkViewConstraintX,checkViewConstraintY,checkViewConstraintW,checkViewConstraintH];
    config.checkViewHorizontalConstraints = config.checkViewConstraints;
    
    
    // 隐私
    CGFloat spacing = checkViewWidth + 20 + 5;
    config.privacyState = YES;
    
    JVLayoutConstraint *privacyConstraintX = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemSuper attribute:NSLayoutAttributeLeft multiplier:1 constant:spacing];
    JVLayoutConstraint *privacyConstraintX2 = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemSuper attribute:NSLayoutAttributeRight multiplier:1 constant:-spacing];
    JVLayoutConstraint *privacyConstraintY = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemSuper attribute:NSLayoutAttributeBottom multiplier:1 constant:-10];
    JVLayoutConstraint *privacyConstraintH = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemNone attribute:NSLayoutAttributeHeight multiplier:1 constant:50];
    config.privacyConstraints = @[privacyConstraintX,privacyConstraintX2,privacyConstraintY,privacyConstraintH];
    config.privacyHorizontalConstraints = config.privacyConstraints;
    
    
    //loading
    JVLayoutConstraint *loadingConstraintX = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeCenterX relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemSuper attribute:NSLayoutAttributeCenterX multiplier:1 constant:0];
    JVLayoutConstraint *loadingConstraintY = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeCenterY relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemSuper attribute:NSLayoutAttributeCenterY multiplier:1 constant:0];
    JVLayoutConstraint *loadingConstraintW = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemNone attribute:NSLayoutAttributeWidth multiplier:1 constant:30];
    JVLayoutConstraint *loadingConstraintH = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemNone attribute:NSLayoutAttributeHeight multiplier:1 constant:30];
    config.loadingConstraints = @[loadingConstraintX,loadingConstraintY,loadingConstraintW,loadingConstraintH];
    config.loadingHorizontalConstraints = config.loadingConstraints;
    
    
    /*
    config.authPageBackgroundImage = [UIImage imageNamed:@"背景图"];
    config.navColor = [UIColor redColor];
    config.preferredStatusBarStyle = 0;
    config.navText = [[NSAttributedString alloc] initWithString:@"自定义标题"];
    config.navReturnImg = [UIImage imageNamed:@"自定义返回键"];
    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
    button.frame = CGRectMake(0, 0, 44, 44);
    button.backgroundColor = [UIColor greenColor];
    config.navControl = [[UIBarButtonItem alloc] initWithCustomView:button];
    config.logoHidden = NO;
    config.logBtnText = @"自定义登录按钮文字";
    config.logBtnTextColor = [UIColor redColor];
    config.numberColor = [UIColor blueColor];
    config.appPrivacyOne = @[@"应用自定义服务条款 1",@"https://www.jiguang.cn/about"];
    config.appPrivacyTwo = @[@"应用自定义服务条款 2",@"https://www.jiguang.cn/about"];
    config.privacyComponents = @[@"文本 1",@"文本 2",@"文本 3",@"文本 4"];
    config.appPrivacyColor = @[[UIColor redColor], [UIColor blueColor]];
    config.sloganTextColor = [UIColor redColor];
    config.navCustom = NO;
    config.numberSize = 24;
    config.privacyState = YES;
     */
    [JVERIFICATIONService customUIWithConfig:config];

        
此代码块在浮窗中显示

授权页面添加自定义控件

支持的版本

开始支持的版本 2.1.0

接口定义

  • + (void)customUIWithConfig:(JVUIConfig *)UIConfig customViews:(void(^)(UIView *customAreaView))customViewsBlk;

    • 接口说明:

      • 自定义授权页面 UI 样式,并添加自定义控件
    • 参数说明:

      • UIConfig JVUIConfig 的子类
      • customViewsBlk 添加自定义视图的 block
    • 调用示例:

OC JVUIConfig *config = [[JVUIConfig alloc] init]; config.navCustom = NO; // config.prefersStatusBarHidden = YES; config.shouldAutorotate = YES; config.autoLayout = YES; // config.orientation = UIInterfaceOrientationPortrait; config.navReturnHidden = NO; config.privacyTextFontSize = 12; config.navText = [[NSAttributedString alloc]initWithString:@"登录统一认证" attributes:@{NSForegroundColorAttributeName:[UIColor whiteColor], NSFontAttributeName:[UIFont systemFontOfSize:18]}]; // config.navColor = [UIColor redColor]; // config.navBarBackGroundImage = [UIImage imageNamed:@"cmccLogo"]; config.privacyTextAlignment = NSTextAlignmentLeft; // config.numberFont = [UIFont systemFontOfSize:10]; // config.logBtnFont = [UIFont systemFontOfSize:5]; // config.privacyShowBookSymbol = YES; // config.privacyLineSpacing = 5; // config.agreementNavBackgroundColor = [UIColor redColor]; // config.sloganFont = [UIFont systemFontOfSize:30]; // config.checkViewHidden = YES; config.modalTransitionStyle = UIModalTransitionStyleCoverVertical; /* config.customLoadingViewBlock = ^(UIView *View) { //https://github.com/jdg/MBProgressHUD MBProgressHUD *hub = [MBProgressHUD showHUDAddedTo:View animated:YES]; hub.backgroundColor = [UIColor clearColor]; hub.label.text = @"正在登录.."; [hub showAnimated:YES]; }; */ /* config.customPrivacyAlertViewBlock = ^(UIViewController *vc) {UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"请点击同意协议" message:nil preferredStyle:UIAlertControllerStyleAlert]; [alert addAction:[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:nil]]; [vc presentViewController:alert animated:true completion:nil]; }; */ //logo config.logoImg = [UIImage imageNamed:@"cmccLogo"]; CGFloat logoWidth = config.logoImg.size.width?:100; CGFloat logoHeight = logoWidth; JVLayoutConstraint *logoConstraintX = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeCenterX relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemSuper attribute:NSLayoutAttributeCenterX multiplier:1 constant:0]; JVLayoutConstraint *logoConstraintY = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemSuper attribute:NSLayoutAttributeCenterY multiplier:1 constant:-90]; JVLayoutConstraint *logoConstraintW = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemNone attribute:NSLayoutAttributeWidth multiplier:1 constant:logoWidth]; JVLayoutConstraint *logoConstraintH = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemNone attribute:NSLayoutAttributeHeight multiplier:1 constant:logoHeight]; config.logoConstraints = @[logoConstraintX,logoConstraintY,logoConstraintW,logoConstraintH]; config.logoHorizontalConstraints = config.logoConstraints; // 号码栏 JVLayoutConstraint *numberConstraintX = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeCenterX relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemSuper attribute:NSLayoutAttributeCenterX multiplier:1 constant:0]; JVLayoutConstraint *numberConstraintY = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeCenterY relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemSuper attribute:NSLayoutAttributeCenterY multiplier:1 constant:-55]; JVLayoutConstraint *numberConstraintW = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemNone attribute:NSLayoutAttributeWidth multiplier:1 constant:130]; JVLayoutConstraint *numberConstraintH = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemNone attribute:NSLayoutAttributeHeight multiplier:1 constant:25]; config.numberConstraints = @[numberConstraintX,numberConstraintY, numberConstraintW, numberConstraintH]; config.numberHorizontalConstraints = config.numberConstraints; //slogan 展示 JVLayoutConstraint *sloganConstraintX = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeCenterX relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemSuper attribute:NSLayoutAttributeCenterX multiplier:1 constant:0]; JVLayoutConstraint *sloganConstraintY = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemSuper attribute:NSLayoutAttributeCenterY multiplier:1 constant:-20]; JVLayoutConstraint *sloganConstraintW = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemNone attribute:NSLayoutAttributeWidth multiplier:1 constant:130]; JVLayoutConstraint *sloganConstraintH = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemNone attribute:NSLayoutAttributeHeight multiplier:1 constant:20]; config.sloganConstraints = @[sloganConstraintX,sloganConstraintY, sloganConstraintW, sloganConstraintH]; config.sloganHorizontalConstraints = config.sloganConstraints; // 登录按钮 UIImage *login_nor_image = [self imageNamed:@"loginBtn_Nor"]; UIImage *login_dis_image = [self imageNamed:@"loginBtn_Dis"]; UIImage *login_hig_image = [self imageNamed:@"loginBtn_Hig"]; if (login_nor_image && login_dis_image && login_hig_image) {config.logBtnImgs = @[login_nor_image, login_dis_image, login_hig_image]; } CGFloat loginButtonWidth = login_nor_image.size.width?:100; CGFloat loginButtonHeight = login_nor_image.size.height?:100; JVLayoutConstraint *loginConstraintX = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeCenterX relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemSuper attribute:NSLayoutAttributeCenterX multiplier:1 constant:0]; JVLayoutConstraint *loginConstraintY = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemSuper attribute:NSLayoutAttributeCenterY multiplier:1 constant:30]; JVLayoutConstraint *loginConstraintW = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemNone attribute:NSLayoutAttributeWidth multiplier:1 constant:loginButtonWidth]; JVLayoutConstraint *loginConstraintH = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemNone attribute:NSLayoutAttributeHeight multiplier:1 constant:loginButtonHeight]; config.logBtnConstraints = @[loginConstraintX,loginConstraintY,loginConstraintW,loginConstraintH]; config.logBtnHorizontalConstraints = config.logBtnConstraints; // 勾选框 UIImage * uncheckedImg = [self imageNamed:@"checkBox_unSelected"]; UIImage * checkedImg = [self imageNamed:@"checkBox_selected"]; CGFloat checkViewWidth = uncheckedImg.size.width; CGFloat checkViewHeight = uncheckedImg.size.height; config.uncheckedImg = uncheckedImg; config.checkedImg = checkedImg; JVLayoutConstraint *checkViewConstraintX = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemSuper attribute:NSLayoutAttributeLeft multiplier:1 constant:20]; JVLayoutConstraint *checkViewConstraintY = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeCenterY relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemPrivacy attribute:NSLayoutAttributeCenterY multiplier:1 constant:0]; JVLayoutConstraint *checkViewConstraintW = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemNone attribute:NSLayoutAttributeWidth multiplier:1 constant:checkViewWidth]; JVLayoutConstraint *checkViewConstraintH = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemNone attribute:NSLayoutAttributeHeight multiplier:1 constant:checkViewHeight]; config.checkViewConstraints = @[checkViewConstraintX,checkViewConstraintY,checkViewConstraintW,checkViewConstraintH]; config.checkViewHorizontalConstraints = config.checkViewConstraints; // 隐私 CGFloat spacing = checkViewWidth + 20 + 5; config.privacyState = YES; JVLayoutConstraint *privacyConstraintX = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemSuper attribute:NSLayoutAttributeLeft multiplier:1 constant:spacing]; JVLayoutConstraint *privacyConstraintX2 = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemSuper attribute:NSLayoutAttributeRight multiplier:1 constant:-spacing]; JVLayoutConstraint *privacyConstraintY = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemSuper attribute:NSLayoutAttributeBottom multiplier:1 constant:-10]; JVLayoutConstraint *privacyConstraintH = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemNone attribute:NSLayoutAttributeHeight multiplier:1 constant:50]; config.privacyConstraints = @[privacyConstraintX,privacyConstraintX2,privacyConstraintY,privacyConstraintH]; config.privacyHorizontalConstraints = config.privacyConstraints; //loading JVLayoutConstraint *loadingConstraintX = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeCenterX relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemSuper attribute:NSLayoutAttributeCenterX multiplier:1 constant:0]; JVLayoutConstraint *loadingConstraintY = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeCenterY relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemSuper attribute:NSLayoutAttributeCenterY multiplier:1 constant:0]; JVLayoutConstraint *loadingConstraintW = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemNone attribute:NSLayoutAttributeWidth multiplier:1 constant:30]; JVLayoutConstraint *loadingConstraintH = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemNone attribute:NSLayoutAttributeHeight multiplier:1 constant:30]; config.loadingConstraints = @[loadingConstraintX,loadingConstraintY,loadingConstraintW,loadingConstraintH]; config.loadingHorizontalConstraints = config.loadingConstraints; /* config.authPageBackgroundImage = [UIImage imageNamed:@"背景图"]; config.navColor = [UIColor redColor]; config.preferredStatusBarStyle = 0; config.navText = [[NSAttributedString alloc] initWithString:@"自定义标题"]; config.navReturnImg = [UIImage imageNamed:@"自定义返回键"]; UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom]; button.frame = CGRectMake(0, 0, 44, 44); button.backgroundColor = [UIColor greenColor]; config.navControl = [[UIBarButtonItem alloc] initWithCustomView:button]; config.logoHidden = NO; config.logBtnText = @"自定义登录按钮文字"; config.logBtnTextColor = [UIColor redColor]; config.numberColor = [UIColor blueColor]; config.appPrivacyOne = @[@"应用自定义服务条款 1",@"https://www.jiguang.cn/about"]; config.appPrivacyTwo = @[@"应用自定义服务条款 2",@"https://www.jiguang.cn/about"]; config.privacyComponents = @[@"文本 1",@"文本 2",@"文本 3",@"文本 4"]; config.appPrivacyColor = @[[UIColor redColor], [UIColor blueColor]]; config.sloganTextColor = [UIColor redColor]; config.navCustom = NO; config.numberSize = 24; config.privacyState = YES; */ [JVERIFICATIONService customUIWithConfig:config customViews:^(UIView *customAreaView) { /* // 添加一个自定义 label UILabel *lable = [[UILabel alloc] init]; lable.text = @"这是一个自定义 label"; [lable sizeToFit]; lable.center = customAreaView.center; [customAreaView addSubview:lable]; */ }]; Swift let config = JVUIConfig() // 导航栏 config.navCustom = false config.navText = NSAttributedString.init(string: "登录统一认证", attributes: [NSAttributedString.Key.foregroundColor: UIColor.white, NSAttributedString.Key.font:UIFont.systemFont(ofSize: 18)]) config.navReturnHidden = false config.shouldAutorotate = true config.autoLayout = true // 弹窗弹出方式 config.modalTransitionStyle = UIModalTransitionStyle.coverVertical //logo config.logoImg = UIImage(named: "cmccLogo") let logoWidth = config.logoImg?.size.width ?? 100 let logoHeight = logoWidth let logoConstraintX = JVLayoutConstraint(attribute: NSLayoutConstraint.Attribute.centerX, relatedBy: NSLayoutConstraint.Relation.equal, to: JVLayoutItem.super, attribute: NSLayoutConstraint.Attribute.centerX, multiplier: 1, constant: 0) let logoConstraintY = JVLayoutConstraint(attribute: NSLayoutConstraint.Attribute.bottom, relatedBy: NSLayoutConstraint.Relation.equal, to: JVLayoutItem.super, attribute: NSLayoutConstraint.Attribute.centerY, multiplier: 1, constant: -90) let logoConstraintW = JVLayoutConstraint(attribute: NSLayoutConstraint.Attribute.width, relatedBy: NSLayoutConstraint.Relation.equal, to: JVLayoutItem.none, attribute: NSLayoutConstraint.Attribute.width, multiplier: 1, constant: logoWidth) let logoConstraintH = JVLayoutConstraint(attribute: NSLayoutConstraint.Attribute.height, relatedBy: NSLayoutConstraint.Relation.equal, to: JVLayoutItem.none, attribute: NSLayoutConstraint.Attribute.height, multiplier: 1, constant: logoHeight) config.logoConstraints = [logoConstraintX!,logoConstraintY!,logoConstraintW!,logoConstraintH!] config.logoHorizontalConstraints = config.logoConstraints // 号码栏 let numberConstraintX = JVLayoutConstraint(attribute: NSLayoutConstraint.Attribute.centerX, relatedBy: NSLayoutConstraint.Relation.equal, to: JVLayoutItem.super, attribute: NSLayoutConstraint.Attribute.centerX, multiplier: 1, constant:0) let numberConstraintY = JVLayoutConstraint(attribute: NSLayoutConstraint.Attribute.centerY, relatedBy: NSLayoutConstraint.Relation.equal, to: JVLayoutItem.super, attribute: NSLayoutConstraint.Attribute.centerY, multiplier: 1, constant:-55) let numberConstraintW = JVLayoutConstraint(attribute: NSLayoutConstraint.Attribute.width, relatedBy: NSLayoutConstraint.Relation.equal, to: JVLayoutItem.none, attribute: NSLayoutConstraint.Attribute.width, multiplier: 1, constant:130) let numberConstraintH = JVLayoutConstraint(attribute: NSLayoutConstraint.Attribute.height, relatedBy: NSLayoutConstraint.Relation.equal, to: JVLayoutItem.none, attribute: NSLayoutConstraint.Attribute.height, multiplier: 1, constant:25) config.numberConstraints = [numberConstraintX!, numberConstraintY!, numberConstraintW!, numberConstraintH!] config.numberHorizontalConstraints = config.numberConstraints //slogan let sloganConstraintX = JVLayoutConstraint(attribute: NSLayoutConstraint.Attribute.centerX, relatedBy: NSLayoutConstraint.Relation.equal, to: JVLayoutItem.super, attribute: NSLayoutConstraint.Attribute.centerX, multiplier: 1, constant:0) let sloganConstraintY = JVLayoutConstraint(attribute: NSLayoutConstraint.Attribute.bottom, relatedBy: NSLayoutConstraint.Relation.equal, to: JVLayoutItem.super, attribute: NSLayoutConstraint.Attribute.centerY, multiplier: 1, constant:-20) let sloganConstraintW = JVLayoutConstraint(attribute: NSLayoutConstraint.Attribute.width, relatedBy: NSLayoutConstraint.Relation.equal, to: JVLayoutItem.none, attribute: NSLayoutConstraint.Attribute.width, multiplier: 1, constant:130) let sloganConstraintH = JVLayoutConstraint(attribute: NSLayoutConstraint.Attribute.height, relatedBy: NSLayoutConstraint.Relation.equal, to: JVLayoutItem.none, attribute: NSLayoutConstraint.Attribute.height, multiplier: 1, constant:20) config.sloganConstraints = [sloganConstraintX!, sloganConstraintY!, sloganConstraintW!, sloganConstraintH!] config.sloganHorizontalConstraints = config.sloganConstraints // 登录按钮 let login_nor_image = imageNamed(name: "loginBtn_Nor") let login_dis_image = imageNamed(name: "loginBtn_Dis") let login_hig_image = imageNamed(name: "loginBtn_Hig") if let norImage = login_nor_image, let disImage = login_dis_image, let higImage = login_hig_image {config.logBtnImgs = [norImage, disImage, higImage] } let loginBtnWidth = login_nor_image?.size.width ?? 100 let loginBtnHeight = login_nor_image?.size.height ?? 100 let loginConstraintX = JVLayoutConstraint(attribute: NSLayoutConstraint.Attribute.centerX, relatedBy: NSLayoutConstraint.Relation.equal, to: JVLayoutItem.super, attribute: NSLayoutConstraint.Attribute.centerX, multiplier: 1, constant:0) let loginConstraintY = JVLayoutConstraint(attribute: NSLayoutConstraint.Attribute.bottom, relatedBy: NSLayoutConstraint.Relation.equal, to: JVLayoutItem.super, attribute: NSLayoutConstraint.Attribute.centerY, multiplier: 1, constant:30) let loginConstraintW = JVLayoutConstraint(attribute: NSLayoutConstraint.Attribute.width, relatedBy: NSLayoutConstraint.Relation.equal, to: JVLayoutItem.none, attribute: NSLayoutConstraint.Attribute.width, multiplier: 1, constant:loginBtnWidth) let loginConstraintH = JVLayoutConstraint(attribute: NSLayoutConstraint.Attribute.height, relatedBy: NSLayoutConstraint.Relation.equal, to: JVLayoutItem.none, attribute: NSLayoutConstraint.Attribute.height, multiplier: 1, constant:loginBtnHeight) config.logBtnConstraints = [loginConstraintX!, loginConstraintY!, loginConstraintW!, loginConstraintH!] config.logBtnHorizontalConstraints = config.logBtnConstraints // 勾选框 let uncheckedImage = imageNamed(name: "checkBox_unSelected") let checkedImage = imageNamed(name: "checkBox_selected") let checkViewWidth = uncheckedImage?.size.width ?? 10 let checkViewHeight = uncheckedImage?.size.height ?? 10 config.uncheckedImg = uncheckedImage config.checkedImg = checkedImage let checkViewConstraintX = JVLayoutConstraint(attribute: NSLayoutConstraint.Attribute.left, relatedBy: NSLayoutConstraint.Relation.equal, to: JVLayoutItem.super, attribute: NSLayoutConstraint.Attribute.left, multiplier: 1, constant:20) let checkViewConstraintY = JVLayoutConstraint(attribute: NSLayoutConstraint.Attribute.centerY, relatedBy: NSLayoutConstraint.Relation.equal, to: JVLayoutItem.privacy, attribute: NSLayoutConstraint.Attribute.centerY, multiplier: 1, constant:0) let checkViewConstraintW = JVLayoutConstraint(attribute: NSLayoutConstraint.Attribute.width, relatedBy: NSLayoutConstraint.Relation.equal, to: JVLayoutItem.none, attribute: NSLayoutConstraint.Attribute.width, multiplier: 1, constant:checkViewWidth) let checkViewConstraintH = JVLayoutConstraint(attribute: NSLayoutConstraint.Attribute.height, relatedBy: NSLayoutConstraint.Relation.equal, to: JVLayoutItem.none, attribute: NSLayoutConstraint.Attribute.height, multiplier: 1, constant:checkViewHeight) config.checkViewConstraints = [checkViewConstraintX!, checkViewConstraintY!, checkViewConstraintW!, checkViewConstraintH!] config.checkViewHorizontalConstraints = config.checkViewConstraints // 隐私 let spacing = checkViewWidth + 20 + 5 config.privacyState = true config.privacyTextFontSize = 12 config.privacyTextAlignment = NSTextAlignment.left config.appPrivacyOne = ["应用自定义服务条款 1","应用自定义服务条款 2"] let privacyConstraintX = JVLayoutConstraint(attribute: NSLayoutConstraint.Attribute.left, relatedBy: NSLayoutConstraint.Relation.equal, to: JVLayoutItem.super, attribute: NSLayoutConstraint.Attribute.left, multiplier: 1, constant:spacing) let privacyConstraintX2 = JVLayoutConstraint(attribute: NSLayoutConstraint.Attribute.right, relatedBy: NSLayoutConstraint.Relation.equal, to: JVLayoutItem.super, attribute: NSLayoutConstraint.Attribute.right, multiplier: 1, constant:-spacing) let privacyConstraintY = JVLayoutConstraint(attribute: NSLayoutConstraint.Attribute.bottom, relatedBy: NSLayoutConstraint.Relation.equal, to: JVLayoutItem.super, attribute: NSLayoutConstraint.Attribute.bottom, multiplier: 1, constant:-10) let privacyConstraintH = JVLayoutConstraint(attribute: NSLayoutConstraint.Attribute.height, relatedBy: NSLayoutConstraint.Relation.equal, to: JVLayoutItem.none, attribute: NSLayoutConstraint.Attribute.height, multiplier: 1, constant:50) config.privacyConstraints = [privacyConstraintX!,privacyConstraintX2!, privacyConstraintY!, privacyConstraintH!] config.privacyHorizontalConstraints = config.privacyConstraints //loading let loadingConstraintX = JVLayoutConstraint(attribute: NSLayoutConstraint.Attribute.centerX, relatedBy: NSLayoutConstraint.Relation.equal, to: JVLayoutItem.super, attribute: NSLayoutConstraint.Attribute.centerX, multiplier: 1, constant:0) let loadingConstraintY = JVLayoutConstraint(attribute: NSLayoutConstraint.Attribute.centerY, relatedBy: NSLayoutConstraint.Relation.equal, to: JVLayoutItem.super, attribute: NSLayoutConstraint.Attribute.centerY, multiplier: 1, constant:0) let loadingConstraintW = JVLayoutConstraint(attribute: NSLayoutConstraint.Attribute.width, relatedBy: NSLayoutConstraint.Relation.equal, to: JVLayoutItem.none, attribute: NSLayoutConstraint.Attribute.width, multiplier: 1, constant:30) let loadingConstraintH = JVLayoutConstraint(attribute: NSLayoutConstraint.Attribute.height, relatedBy: NSLayoutConstraint.Relation.equal, to: JVLayoutItem.none, attribute: NSLayoutConstraint.Attribute.height, multiplier: 1, constant:30) config.loadingConstraints = [loadingConstraintX!, loadingConstraintY!, loadingConstraintW!, loadingConstraintH!] config.loadingHorizontalConstraints = config.loadingConstraints JVERIFICATIONService.customUI(with: config) {(customView) in // 自定义 view, 加到 customView 上 guard let customV = customView else {return} let label = UILabel() label.text = "customLabel" label.frame = CGRect(x: 0, y: 0, width: 60, height: 30) customV.addSubview(label) }
          OC          
    JVUIConfig *config = [[JVUIConfig alloc] init];
    config.navCustom = NO;
//    config.prefersStatusBarHidden = YES;
    config.shouldAutorotate = YES;
    config.autoLayout = YES;
//    config.orientation =  UIInterfaceOrientationPortrait;
    
    config.navReturnHidden = NO;
    config.privacyTextFontSize = 12;
    config.navText = [[NSAttributedString alloc]initWithString:@"登录统一认证" attributes:@{NSForegroundColorAttributeName:[UIColor whiteColor], NSFontAttributeName:[UIFont systemFontOfSize:18]}];
//    config.navColor = [UIColor redColor];
//    config.navBarBackGroundImage = [UIImage imageNamed:@"cmccLogo"];
    config.privacyTextAlignment = NSTextAlignmentLeft;
//    config.numberFont = [UIFont systemFontOfSize:10];
//    config.logBtnFont = [UIFont systemFontOfSize:5];
//    config.privacyShowBookSymbol = YES;
//    config.privacyLineSpacing = 5;
//    config.agreementNavBackgroundColor = [UIColor redColor];
//    config.sloganFont = [UIFont systemFontOfSize:30];
//    config.checkViewHidden = YES;
    config.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
    
    /*
    config.customLoadingViewBlock = ^(UIView *View) {
        
        //https://github.com/jdg/MBProgressHUD
        MBProgressHUD *hub = [MBProgressHUD showHUDAddedTo:View animated:YES];
        hub.backgroundColor = [UIColor clearColor];
        hub.label.text = @"正在登录..";
        [hub showAnimated:YES];
    };
    */
    
    /*
    config.customPrivacyAlertViewBlock = ^(UIViewController *vc) {UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"请点击同意协议" message:nil preferredStyle:UIAlertControllerStyleAlert];
        [alert addAction:[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:nil]];
        [vc presentViewController:alert animated:true completion:nil];
    };
    */
     
    
    //logo
    config.logoImg = [UIImage imageNamed:@"cmccLogo"];
    CGFloat logoWidth = config.logoImg.size.width?:100;
    CGFloat logoHeight = logoWidth;
    JVLayoutConstraint *logoConstraintX = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeCenterX relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemSuper attribute:NSLayoutAttributeCenterX multiplier:1 constant:0];
    JVLayoutConstraint *logoConstraintY = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemSuper attribute:NSLayoutAttributeCenterY multiplier:1 constant:-90];
    JVLayoutConstraint *logoConstraintW = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemNone attribute:NSLayoutAttributeWidth multiplier:1 constant:logoWidth];
    JVLayoutConstraint *logoConstraintH = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemNone attribute:NSLayoutAttributeHeight multiplier:1 constant:logoHeight];
    config.logoConstraints = @[logoConstraintX,logoConstraintY,logoConstraintW,logoConstraintH];
    config.logoHorizontalConstraints = config.logoConstraints;

    
    
    // 号码栏
    JVLayoutConstraint *numberConstraintX = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeCenterX relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemSuper attribute:NSLayoutAttributeCenterX multiplier:1 constant:0];
    JVLayoutConstraint *numberConstraintY = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeCenterY relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemSuper attribute:NSLayoutAttributeCenterY multiplier:1 constant:-55];
    JVLayoutConstraint *numberConstraintW = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemNone attribute:NSLayoutAttributeWidth multiplier:1 constant:130];
    JVLayoutConstraint *numberConstraintH = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemNone attribute:NSLayoutAttributeHeight multiplier:1 constant:25];
    config.numberConstraints = @[numberConstraintX,numberConstraintY, numberConstraintW, numberConstraintH];
    config.numberHorizontalConstraints = config.numberConstraints;
    
    //slogan 展示
    JVLayoutConstraint *sloganConstraintX = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeCenterX relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemSuper attribute:NSLayoutAttributeCenterX multiplier:1 constant:0];
    JVLayoutConstraint *sloganConstraintY = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemSuper attribute:NSLayoutAttributeCenterY multiplier:1 constant:-20];
    JVLayoutConstraint *sloganConstraintW = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemNone attribute:NSLayoutAttributeWidth multiplier:1 constant:130];
    JVLayoutConstraint *sloganConstraintH = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemNone attribute:NSLayoutAttributeHeight multiplier:1 constant:20];
    config.sloganConstraints = @[sloganConstraintX,sloganConstraintY, sloganConstraintW, sloganConstraintH];
    config.sloganHorizontalConstraints = config.sloganConstraints;
    
    
    // 登录按钮
    UIImage *login_nor_image = [self imageNamed:@"loginBtn_Nor"];
    UIImage *login_dis_image = [self imageNamed:@"loginBtn_Dis"];
    UIImage *login_hig_image = [self imageNamed:@"loginBtn_Hig"];
    if (login_nor_image && login_dis_image && login_hig_image) {config.logBtnImgs = @[login_nor_image, login_dis_image, login_hig_image];
    }
    CGFloat loginButtonWidth = login_nor_image.size.width?:100;
    CGFloat loginButtonHeight = login_nor_image.size.height?:100;
    JVLayoutConstraint *loginConstraintX = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeCenterX relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemSuper attribute:NSLayoutAttributeCenterX multiplier:1 constant:0];
    JVLayoutConstraint *loginConstraintY = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemSuper attribute:NSLayoutAttributeCenterY multiplier:1 constant:30];
    JVLayoutConstraint *loginConstraintW = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemNone attribute:NSLayoutAttributeWidth multiplier:1 constant:loginButtonWidth];
    JVLayoutConstraint *loginConstraintH = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemNone attribute:NSLayoutAttributeHeight multiplier:1 constant:loginButtonHeight];
    config.logBtnConstraints = @[loginConstraintX,loginConstraintY,loginConstraintW,loginConstraintH];
    config.logBtnHorizontalConstraints = config.logBtnConstraints;
    
    // 勾选框
    UIImage * uncheckedImg = [self imageNamed:@"checkBox_unSelected"];
    UIImage * checkedImg = [self imageNamed:@"checkBox_selected"];
    CGFloat checkViewWidth = uncheckedImg.size.width;
    CGFloat checkViewHeight = uncheckedImg.size.height;
    config.uncheckedImg = uncheckedImg;
    config.checkedImg = checkedImg;
    JVLayoutConstraint *checkViewConstraintX = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemSuper attribute:NSLayoutAttributeLeft multiplier:1 constant:20];
    JVLayoutConstraint *checkViewConstraintY = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeCenterY relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemPrivacy attribute:NSLayoutAttributeCenterY multiplier:1 constant:0];
    JVLayoutConstraint *checkViewConstraintW = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemNone attribute:NSLayoutAttributeWidth multiplier:1 constant:checkViewWidth];
    JVLayoutConstraint *checkViewConstraintH = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemNone attribute:NSLayoutAttributeHeight multiplier:1 constant:checkViewHeight];
    config.checkViewConstraints = @[checkViewConstraintX,checkViewConstraintY,checkViewConstraintW,checkViewConstraintH];
    config.checkViewHorizontalConstraints = config.checkViewConstraints;
    
    
    // 隐私
    CGFloat spacing = checkViewWidth + 20 + 5;
    config.privacyState = YES;
    
    JVLayoutConstraint *privacyConstraintX = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemSuper attribute:NSLayoutAttributeLeft multiplier:1 constant:spacing];
    JVLayoutConstraint *privacyConstraintX2 = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemSuper attribute:NSLayoutAttributeRight multiplier:1 constant:-spacing];
    JVLayoutConstraint *privacyConstraintY = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemSuper attribute:NSLayoutAttributeBottom multiplier:1 constant:-10];
    JVLayoutConstraint *privacyConstraintH = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemNone attribute:NSLayoutAttributeHeight multiplier:1 constant:50];
    config.privacyConstraints = @[privacyConstraintX,privacyConstraintX2,privacyConstraintY,privacyConstraintH];
    config.privacyHorizontalConstraints = config.privacyConstraints;
    
    
    //loading
    JVLayoutConstraint *loadingConstraintX = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeCenterX relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemSuper attribute:NSLayoutAttributeCenterX multiplier:1 constant:0];
    JVLayoutConstraint *loadingConstraintY = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeCenterY relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemSuper attribute:NSLayoutAttributeCenterY multiplier:1 constant:0];
    JVLayoutConstraint *loadingConstraintW = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemNone attribute:NSLayoutAttributeWidth multiplier:1 constant:30];
    JVLayoutConstraint *loadingConstraintH = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemNone attribute:NSLayoutAttributeHeight multiplier:1 constant:30];
    config.loadingConstraints = @[loadingConstraintX,loadingConstraintY,loadingConstraintW,loadingConstraintH];
    config.loadingHorizontalConstraints = config.loadingConstraints;
    
    
    /*
    config.authPageBackgroundImage = [UIImage imageNamed:@"背景图"];
    config.navColor = [UIColor redColor];
    config.preferredStatusBarStyle = 0;
    config.navText = [[NSAttributedString alloc] initWithString:@"自定义标题"];
    config.navReturnImg = [UIImage imageNamed:@"自定义返回键"];
    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
    button.frame = CGRectMake(0, 0, 44, 44);
    button.backgroundColor = [UIColor greenColor];
    config.navControl = [[UIBarButtonItem alloc] initWithCustomView:button];
    config.logoHidden = NO;
    config.logBtnText = @"自定义登录按钮文字";
    config.logBtnTextColor = [UIColor redColor];
    config.numberColor = [UIColor blueColor];
    config.appPrivacyOne = @[@"应用自定义服务条款 1",@"https://www.jiguang.cn/about"];
    config.appPrivacyTwo = @[@"应用自定义服务条款 2",@"https://www.jiguang.cn/about"];
    config.privacyComponents = @[@"文本 1",@"文本 2",@"文本 3",@"文本 4"];
    config.appPrivacyColor = @[[UIColor redColor], [UIColor blueColor]];
    config.sloganTextColor = [UIColor redColor];
    config.navCustom = NO;
    config.numberSize = 24;
    config.privacyState = YES;
     */
    [JVERIFICATIONService customUIWithConfig:config customViews:^(UIView *customAreaView) {
        /*
        // 添加一个自定义 label
        UILabel *lable  = [[UILabel alloc] init];
        lable.text = @"这是一个自定义 label";
        [lable sizeToFit];
        lable.center = customAreaView.center;
        [customAreaView addSubview:lable];
         */
        
    }];
    
Swift
  let config = JVUIConfig()
   // 导航栏
   config.navCustom = false
   config.navText = NSAttributedString.init(string: "登录统一认证", attributes: [NSAttributedString.Key.foregroundColor: UIColor.white, NSAttributedString.Key.font:UIFont.systemFont(ofSize: 18)])
   config.navReturnHidden = false
        
   config.shouldAutorotate = true
   config.autoLayout = true
   // 弹窗弹出方式
   config.modalTransitionStyle = UIModalTransitionStyle.coverVertical
   //logo
   config.logoImg = UIImage(named: "cmccLogo")
   let logoWidth = config.logoImg?.size.width ?? 100
   let logoHeight = logoWidth
   let logoConstraintX = JVLayoutConstraint(attribute: NSLayoutConstraint.Attribute.centerX, relatedBy: NSLayoutConstraint.Relation.equal, to: JVLayoutItem.super, attribute: NSLayoutConstraint.Attribute.centerX, multiplier: 1, constant: 0)
   let logoConstraintY = JVLayoutConstraint(attribute: NSLayoutConstraint.Attribute.bottom, relatedBy: NSLayoutConstraint.Relation.equal, to: JVLayoutItem.super, attribute: NSLayoutConstraint.Attribute.centerY, multiplier: 1, constant: -90)
   let logoConstraintW = JVLayoutConstraint(attribute: NSLayoutConstraint.Attribute.width, relatedBy: NSLayoutConstraint.Relation.equal, to: JVLayoutItem.none, attribute: NSLayoutConstraint.Attribute.width, multiplier: 1, constant: logoWidth)
   let logoConstraintH = JVLayoutConstraint(attribute: NSLayoutConstraint.Attribute.height, relatedBy: NSLayoutConstraint.Relation.equal, to: JVLayoutItem.none, attribute: NSLayoutConstraint.Attribute.height, multiplier: 1, constant: logoHeight)
   config.logoConstraints = [logoConstraintX!,logoConstraintY!,logoConstraintW!,logoConstraintH!]
   config.logoHorizontalConstraints = config.logoConstraints
        
    // 号码栏
   let numberConstraintX = JVLayoutConstraint(attribute: NSLayoutConstraint.Attribute.centerX, relatedBy: NSLayoutConstraint.Relation.equal, to: JVLayoutItem.super, attribute: NSLayoutConstraint.Attribute.centerX, multiplier: 1, constant:0)
   let numberConstraintY = JVLayoutConstraint(attribute: NSLayoutConstraint.Attribute.centerY, relatedBy: NSLayoutConstraint.Relation.equal, to: JVLayoutItem.super, attribute: NSLayoutConstraint.Attribute.centerY, multiplier: 1, constant:-55)
   let numberConstraintW = JVLayoutConstraint(attribute: NSLayoutConstraint.Attribute.width, relatedBy: NSLayoutConstraint.Relation.equal, to: JVLayoutItem.none, attribute: NSLayoutConstraint.Attribute.width, multiplier: 1, constant:130)
   let numberConstraintH = JVLayoutConstraint(attribute: NSLayoutConstraint.Attribute.height, relatedBy: NSLayoutConstraint.Relation.equal, to: JVLayoutItem.none, attribute: NSLayoutConstraint.Attribute.height, multiplier: 1, constant:25)
   config.numberConstraints = [numberConstraintX!, numberConstraintY!, numberConstraintW!, numberConstraintH!]
   config.numberHorizontalConstraints = config.numberConstraints
        
    //slogan
    let sloganConstraintX = JVLayoutConstraint(attribute: NSLayoutConstraint.Attribute.centerX, relatedBy: NSLayoutConstraint.Relation.equal, to: JVLayoutItem.super, attribute: NSLayoutConstraint.Attribute.centerX, multiplier: 1, constant:0)
    let sloganConstraintY = JVLayoutConstraint(attribute: NSLayoutConstraint.Attribute.bottom, relatedBy: NSLayoutConstraint.Relation.equal, to: JVLayoutItem.super, attribute: NSLayoutConstraint.Attribute.centerY, multiplier: 1, constant:-20)
    let sloganConstraintW = JVLayoutConstraint(attribute: NSLayoutConstraint.Attribute.width, relatedBy: NSLayoutConstraint.Relation.equal, to: JVLayoutItem.none, attribute: NSLayoutConstraint.Attribute.width, multiplier: 1, constant:130)
    let sloganConstraintH = JVLayoutConstraint(attribute: NSLayoutConstraint.Attribute.height, relatedBy: NSLayoutConstraint.Relation.equal, to: JVLayoutItem.none, attribute: NSLayoutConstraint.Attribute.height, multiplier: 1, constant:20)
    config.sloganConstraints = [sloganConstraintX!, sloganConstraintY!, sloganConstraintW!, sloganConstraintH!]
    config.sloganHorizontalConstraints = config.sloganConstraints
        
     // 登录按钮
     let login_nor_image = imageNamed(name: "loginBtn_Nor")
     let login_dis_image = imageNamed(name: "loginBtn_Dis")
     let login_hig_image = imageNamed(name: "loginBtn_Hig")
     if let norImage = login_nor_image, let disImage = login_dis_image, let higImage = login_hig_image {config.logBtnImgs = [norImage, disImage, higImage]
       }
     let loginBtnWidth = login_nor_image?.size.width ?? 100
     let loginBtnHeight = login_nor_image?.size.height ?? 100
     let loginConstraintX = JVLayoutConstraint(attribute: NSLayoutConstraint.Attribute.centerX, relatedBy: NSLayoutConstraint.Relation.equal, to: JVLayoutItem.super, attribute: NSLayoutConstraint.Attribute.centerX, multiplier: 1, constant:0)
     let loginConstraintY = JVLayoutConstraint(attribute: NSLayoutConstraint.Attribute.bottom, relatedBy: NSLayoutConstraint.Relation.equal, to: JVLayoutItem.super, attribute: NSLayoutConstraint.Attribute.centerY, multiplier: 1, constant:30)
     let loginConstraintW = JVLayoutConstraint(attribute: NSLayoutConstraint.Attribute.width, relatedBy: NSLayoutConstraint.Relation.equal, to: JVLayoutItem.none, attribute: NSLayoutConstraint.Attribute.width, multiplier: 1, constant:loginBtnWidth)
     let loginConstraintH = JVLayoutConstraint(attribute: NSLayoutConstraint.Attribute.height, relatedBy: NSLayoutConstraint.Relation.equal, to: JVLayoutItem.none, attribute: NSLayoutConstraint.Attribute.height, multiplier: 1, constant:loginBtnHeight)
     config.logBtnConstraints = [loginConstraintX!, loginConstraintY!, loginConstraintW!, loginConstraintH!]
     config.logBtnHorizontalConstraints = config.logBtnConstraints
        
     // 勾选框
     let uncheckedImage = imageNamed(name: "checkBox_unSelected")
     let checkedImage = imageNamed(name: "checkBox_selected")
     let checkViewWidth = uncheckedImage?.size.width ?? 10
     let checkViewHeight = uncheckedImage?.size.height ?? 10
     config.uncheckedImg = uncheckedImage
     config.checkedImg = checkedImage
     let checkViewConstraintX = JVLayoutConstraint(attribute: NSLayoutConstraint.Attribute.left, relatedBy: NSLayoutConstraint.Relation.equal, to: JVLayoutItem.super, attribute: NSLayoutConstraint.Attribute.left, multiplier: 1, constant:20)
     let checkViewConstraintY = JVLayoutConstraint(attribute: NSLayoutConstraint.Attribute.centerY, relatedBy: NSLayoutConstraint.Relation.equal, to: JVLayoutItem.privacy, attribute: NSLayoutConstraint.Attribute.centerY, multiplier: 1, constant:0)
     let checkViewConstraintW = JVLayoutConstraint(attribute: NSLayoutConstraint.Attribute.width, relatedBy: NSLayoutConstraint.Relation.equal, to: JVLayoutItem.none, attribute: NSLayoutConstraint.Attribute.width, multiplier: 1, constant:checkViewWidth)
     let checkViewConstraintH = JVLayoutConstraint(attribute: NSLayoutConstraint.Attribute.height, relatedBy: NSLayoutConstraint.Relation.equal, to: JVLayoutItem.none, attribute: NSLayoutConstraint.Attribute.height, multiplier: 1, constant:checkViewHeight)
     config.checkViewConstraints = [checkViewConstraintX!, checkViewConstraintY!, checkViewConstraintW!, checkViewConstraintH!]
     config.checkViewHorizontalConstraints = config.checkViewConstraints
        
     // 隐私
     let spacing = checkViewWidth + 20 + 5
     config.privacyState = true
     config.privacyTextFontSize = 12
     config.privacyTextAlignment = NSTextAlignment.left
     config.appPrivacyOne = ["应用自定义服务条款 1","应用自定义服务条款 2"]
     let privacyConstraintX = JVLayoutConstraint(attribute: NSLayoutConstraint.Attribute.left, relatedBy: NSLayoutConstraint.Relation.equal, to: JVLayoutItem.super, attribute: NSLayoutConstraint.Attribute.left, multiplier: 1, constant:spacing)
     let privacyConstraintX2 = JVLayoutConstraint(attribute: NSLayoutConstraint.Attribute.right, relatedBy: NSLayoutConstraint.Relation.equal, to: JVLayoutItem.super, attribute: NSLayoutConstraint.Attribute.right, multiplier: 1, constant:-spacing)
     let privacyConstraintY = JVLayoutConstraint(attribute: NSLayoutConstraint.Attribute.bottom, relatedBy: NSLayoutConstraint.Relation.equal, to: JVLayoutItem.super, attribute: NSLayoutConstraint.Attribute.bottom, multiplier: 1, constant:-10)
     let privacyConstraintH = JVLayoutConstraint(attribute: NSLayoutConstraint.Attribute.height, relatedBy: NSLayoutConstraint.Relation.equal, to: JVLayoutItem.none, attribute: NSLayoutConstraint.Attribute.height, multiplier: 1, constant:50)
     config.privacyConstraints = [privacyConstraintX!,privacyConstraintX2!, privacyConstraintY!, privacyConstraintH!]
     config.privacyHorizontalConstraints = config.privacyConstraints
        
    //loading
     let loadingConstraintX = JVLayoutConstraint(attribute: NSLayoutConstraint.Attribute.centerX, relatedBy: NSLayoutConstraint.Relation.equal, to: JVLayoutItem.super, attribute: NSLayoutConstraint.Attribute.centerX, multiplier: 1, constant:0)
     let loadingConstraintY = JVLayoutConstraint(attribute: NSLayoutConstraint.Attribute.centerY, relatedBy: NSLayoutConstraint.Relation.equal, to: JVLayoutItem.super, attribute: NSLayoutConstraint.Attribute.centerY, multiplier: 1, constant:0)
     let loadingConstraintW = JVLayoutConstraint(attribute: NSLayoutConstraint.Attribute.width, relatedBy: NSLayoutConstraint.Relation.equal, to: JVLayoutItem.none, attribute: NSLayoutConstraint.Attribute.width, multiplier: 1, constant:30)
     let loadingConstraintH = JVLayoutConstraint(attribute: NSLayoutConstraint.Attribute.height, relatedBy: NSLayoutConstraint.Relation.equal, to: JVLayoutItem.none, attribute: NSLayoutConstraint.Attribute.height, multiplier: 1, constant:30)
     config.loadingConstraints = [loadingConstraintX!, loadingConstraintY!, loadingConstraintW!, loadingConstraintH!]
     config.loadingHorizontalConstraints = config.loadingConstraints
        
     JVERIFICATIONService.customUI(with: config) {(customView) in
        // 自定义 view, 加到 customView 上
        guard let customV = customView else {return}
        let label = UILabel()
        label.text = "customLabel"
        label.frame = CGRect(x: 0, y: 0, width: 60, height: 30)
        customV.addSubview(label)
    }
    

        
此代码块在浮窗中显示

创建 JVLayoutConstraint 布局对象

  • +(instancetype _Nullable )constraintWithAttribute:(NSLayoutAttribute)attr1 relatedBy:(NSLayoutRelation)relation toItem:(JVLayoutItem)item attribute:(NSLayoutAttribute)attr2 multiplier:(CGFloat)multiplier constant:(CGFloat)c;

  • 接口说明:

    • 创建 JVLayoutConstraint 布局对象
  • 参数说明:

    • attr1 约束类型
    • relation 与参照视图之间的约束关系
    • item 参照 item
    • attr2 参照 item 约束类型
    • multiplier 乘数
    • c 常量
  • 调用示例:

CGFloat windowW = 300; CGFloat windowH = 300; JVLayoutConstraint *windowConstraintX = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeCenterX relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemSuper attribute:NSLayoutAttributeCenterX multiplier:1 constant:0]; JVLayoutConstraint *windowConstraintY = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeCenterY relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemSuper attribute:NSLayoutAttributeCenterY multiplier:1 constant:0]; JVLayoutConstraint *windowConstraintW = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemNone attribute:NSLayoutAttributeWidth multiplier:1 constant:windowW]; JVLayoutConstraint *windowConstraintH = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemNone attribute:NSLayoutAttributeHeight multiplier:1 constant:windowH]; config.windowConstraints = @[windowConstraintX,windowConstraintY,windowConstraintW,windowConstraintH];
              CGFloat windowW = 300;
    CGFloat windowH = 300;
    JVLayoutConstraint *windowConstraintX = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeCenterX relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemSuper attribute:NSLayoutAttributeCenterX multiplier:1 constant:0];
    JVLayoutConstraint *windowConstraintY = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeCenterY relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemSuper attribute:NSLayoutAttributeCenterY multiplier:1 constant:0];
    JVLayoutConstraint *windowConstraintW = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemNone attribute:NSLayoutAttributeWidth multiplier:1 constant:windowW];
    JVLayoutConstraint *windowConstraintH = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemNone attribute:NSLayoutAttributeHeight multiplier:1 constant:windowH];
    config.windowConstraints = @[windowConstraintX,windowConstraintY,windowConstraintW,windowConstraintH];

        
此代码块在浮窗中显示

JVLayoutItem 枚举

枚举值 枚举说明
JVLayoutItemNone 不参照任何 item。可用来直接设置 width、height
JVLayoutItemLogo 参照 logo 视图
JVLayoutItemNumber 参照号码栏
JVLayoutItemSlogan 参照标语栏
JVLayoutItemLogin 参照登录按钮
JVLayoutItemCheck 参照隐私选择框
JVLayoutItemPrivacy 参照隐私栏
JVLayoutItemSuper 参照父视图

JVLayoutConstraint 类

属性说明:

参数名称 参数类型 参数说明
firstAttribute NSLayoutAttribute 约束类型
relation NSLayoutRelation 与参考视图之间的约束关系
item JVLayoutItem 参照 item
attr2 NSLayoutAttribute 参照 item 约束类型
multiplier CGFloat 乘数
c CGFloat 常量

JVAuthConfig 类

应用配置信息类。以下是属性说明:

参数名称 参数类型 参数说明
AppKey NSString 极光系统应用唯一标识,必填
channel NSString 应用发布渠道,可选
advertisingId NSString 广告标识符,可选
timeout NSTimeInterval 设置初始化超时时间,单位毫秒,合法范围是(0,30000],推荐设置为 5000-10000, 默认值为 10000
isProduction BOOL 是否生产环境。如果为开发状态,设置为 NO;如果为生产状态,应改为 YES。可选,默认为 NO
authBlock Block 初始化回调,包含 code 和 content 两个参数。在 timeout 时间内未完成则返回超时
  • 设置一键登录页面背景视频方法
    • +(void)setVideoBackgroudResource:(NSString *)path placeHolder:(NSString *)imageName;

      • 参数说明

        • path 视频路径支持在线 url 或者本地视频路径
        • imageName 视频未准备好播放时的占位图片名称
      • 调用示例

// 在线视频 NSString *urlStr = @"在线视频地址"; /* 本地视频 NSString *urlStr = [[NSBundle mainBundle] pathForResource:@"本地视频文件地址" ofType:@"本地文件类型"]; **/ [config setVideoBackgroudResource:urlStr placeHolder:@"cmBackground.jpeg"];
          // 在线视频
NSString *urlStr = @"在线视频地址";
/*
本地视频
NSString *urlStr = [[NSBundle mainBundle] pathForResource:@"本地视频文件地址" ofType:@"本地文件类型"];
**/  
 [config setVideoBackgroudResource:urlStr placeHolder:@"cmBackground.jpeg"];
 

        
此代码块在浮窗中显示

JVUIConfig 类

授权界面 UI 配置基类。以下是属性说明:

  • 授权页面设置
参数名称 参数类型 参数说明
authPageBackgroundImage UIImage 授权界面背景图片
authPageGifImagePath NSString 授权界面背景 gif 资源路径,与 authPageBackgroundImage 属性互斥
autoLayout BOOL 是否使用 autoLayout,默认 YES,
shouldAutorotate BOOL 是否支持自动旋转 默认 YES
orientation UIInterfaceOrientation 设置进入授权页的屏幕方向,不支持 UIInterfaceOrientationPortraitUpsideDown
modalTransitionStyle UIModalTransitionStyle 授权页弹出方式, 弹窗模式下不支持 UIModalTransitionStylePartialCurl
dismissAnimationFlag BOOL 关闭授权页是否有动画。默认 YES, 有动画。参数仅作用于以下两种情况:1、一键登录接口设置登录完成后,自动关闭授权页 2、用户点击授权页关闭按钮,关闭授权页
  • 导航栏
参数名称 参数类型 参数说明
navCustom BOOL 是否隐藏导航栏(适配全屏图片)
navColor UIColor 导航栏颜色
barStyle UIBarStyle 此方法从 v2.5.0 版本开始已废弃。建议使用 preferredStatusBarStyle 控制状态栏。preferredStatusBarStyle 默认为 UIStatusBarStyleDefault, 当 barStyle 的效果和 preferredStatusBarStyle 冲突时,barStyle 的效果会失效。
preferredStatusBarStyle UIStatusBarStyle 授权页 preferred status bar style,取代 barStyle 参数
navText NSAttributedString 导航栏标题
navReturnImg UIImage 导航返回图标
navControl UIBarButtonItem 导航栏右侧自定义控件
prefersStatusBarHidden BOOL 竖屏情况下,是否隐藏状态栏。默认 NO. 在项目的 Info.plist 文件里设置 UIViewControllerBasedStatusBarAppearance 为 YES. 注意:弹窗模式下无效,是否隐藏由外部控制器控制
navTransparent BOOL 导航栏是否透明,默认不透明。此参数和 navBarBackGroundImage 冲突,应避免同时使用
navReturnHidden BOOL 导航栏默认返回按钮隐藏,默认不隐藏
navReturnImageEdgeInsets UIEdgeInsets 导航栏返回按钮图片缩进, 默认为 UIEdgeInsetsZero
navDividingLineHidden BOOL 导航栏分割线是否隐藏,默认隐藏
navBarBackGroundImage UIImage 导航栏背景图片. 此参数和 navTransparent 冲突,应避免同时使用
  • LOGO
参数名称 参数类型 参数说明
logoImg UIImage LOGO 图片
logoWidth CGFloat LOGO 图片宽度
logoHeight CGFloat LOGO 图片高度
logoOffsetY CGFloat LOGO 图片偏移量
logoConstraints NSArray LOGO 图片布局对象
logoHorizontalConstraints NSArray LOGO 图片 横屏布局,横屏时优先级高于 logoConstraints
logoHidden BOOL LOGO 图片隐藏
  • 登录按钮
参数名称 参数类型 参数说明
logBtnText NSString 登录按钮文本
logBtnOffsetY CGFloat 登录按钮 Y 偏移量
logBtnConstraints NSArray 登录按钮布局对象
logBtnHorizontalConstraints NSArray 登录按钮 横屏布局,横屏时优先级高于 logBtnConstraints
logBtnTextColor UIImage 登录按钮文本颜色
logBtnFont UIFont 登录按钮字体,默认跟随系统
logBtnImgs UIColor 登录按钮背景图片添加到数组(顺序如下) @[激活状态的图片, 失效状态的图片, 高亮状态的图片]
  • 手机号码
参数名称 参数类型 参数说明
numberColor UIColor 手机号码字体颜色
numberSize CGFloat 手机号码字体大小
numberFont UIFont 手机号码字体,优先级高于 numberSize
numFieldOffsetY CGFloat 号码栏 Y 偏移量
numberConstraints NSArray 号码栏布局对象
numberHorizontalConstraints NSArray 号码栏 横屏布局, 横屏时优先级高于 numberConstraints
  • checkBox
参数名称 参数类型 参数说明
uncheckedImg UIImage checkBox 未选中时图片
checkedImg UIImage checkBox 选中时图片
checkViewConstraints NSArray checkBox 布局对象
checkViewHorizontalConstraints NSArray checkBox 横屏布局,横屏优先级高于 checkViewConstraints
checkViewHidden BOOL checkBox 是否隐藏,默认不隐藏
privacyState BOOL 隐私条款 check 框默认状态 默认:NO
  • 隐私协议栏
参数名称 参数类型 参数说明
appPrivacyOne NSArray 隐私条款一: 数组(务必按顺序)@[条款名称, 条款链接];支持在线文件和 NSBundle 本地文件,沙盒中文件仅支持 NSTemporaryDirectory()路径下文件,274 及之后版本设置无效
appPrivacyTwo NSArray 隐私条款二: 数组(务必按顺序)@[条款名称, 条款链接];支持在线文件和 NSBundle 本地文件,沙盒中文件仅支持 NSTemporaryDirectory()路径下文件,274 及之后版本设置无效
appPrivacyColor UIImage 隐私条款名称颜色 @[基础文字颜色, 条款颜色]
privacyTextFontSize CGFloat 隐私条款字体大小,默认 12
privacyOffsetY CGFloat 隐私条款 Y 偏移量(注: 此属性为与屏幕底部的距离)
privacyComponents NSArray 隐私条款拼接文本数组
privacyConstraints NSArray 隐私条款布局对象
privacyHorizontalConstraints NSArray 隐私条款 横屏布局,横屏下优先级高于 privacyConstraints
privacyTextFontSize CGFloat 隐私条款字体大小,默认 12
privacyTextAlignment NSTextAlignment 隐私条款文本对齐方式,目前仅支持 left、center
privacyShowBookSymbol BOOL 隐私条款是否显示书名号,默认不显示
privacyLineSpacing CGFloat 隐私条款行距,默认跟随系统
customPrivacyAlertViewBlock Block 类型 自定义 Alert view, 当隐私条款未选中时, 点击登录按钮时回调。当此参数存在时, 未选中隐私条款的情况下,登录按钮可以被点击,block 内部参数为自定义 Alert view 可被添加的控制器,详细用法可参见示例 demo
isAlertPrivacyVC BOOL 类型 是否在未勾选隐私协议的情况下 弹窗提示窗口
appPrivacys NSArray 隐私条款组合: 数组 @[privacyComponents, 条款名称, 条款链接] 条款链接, 支持在线文件和 NSBundle 本地文件, 沙盒中文件仅支持 NSTemporaryDirectory() 路径下文件 since2.7.4
openPrivacyInBrowser BOOL 隐私协议点击是否用浏览器打开,默认否。since 2.9.4
  • 隐私协议栏添加辅文本属性

    • (void)addPrivacyTextAttribute:(NSAttributedStringKey *)name value: (id)value range:(NSRange)range;

      • 参数说明

        • name NSAttributedStringKey
        • value NSAttributedStringKey 对应的值
        • range 对应字符串范围
      • 调用示例

      [config addPrivacyTextAttribute:NSUnderlineStyleAttributeName value:@(NSUnderlineStyleSingle) range: NSMakeRange(5, 10)];
                    [config addPrivacyTextAttribute:NSUnderlineStyleAttributeName value:@(NSUnderlineStyleSingle) range: NSMakeRange(5, 10)];
      
              
      此代码块在浮窗中显示
  • 隐私协议页面

参数名称 参数类型 参数说明
agreementNavBackgroundColor UIColor 协议页导航栏背景颜色
agreementNavText NSAttributedString 运营商协议的协议页面导航栏标题
firstPrivacyAgreementNavText NSAttributedString 自定义协议 1 的协议页面导航栏标题
secondPrivacyAgreementNavText NSAttributedString 自定义协议 2 的协议页面导航栏标题
agreementNavReturnImage UIImage 协议页导航栏返回按钮图片
agreementPreferredStatusBarStyle UIStatusBarStyle 协议页 preferred status bar style,取代 barStyle 参数
agreementNavTextFont UIFont 设置授权页点击隐私协议,进入协议页时, 协议页自定义导航栏标题的字体 当 agreementNavText、secondPrivacyAgreementNavText、 firstPrivacyAgreementNavText 存在时不生效 since2.7.4
agreementNavTextColor UIColor 设置授权页点击隐私协议,进入协议页时, 协议页自定义导航栏标题的颜色 当 agreementNavText、secondPrivacyAgreementNavText、 firstPrivacyAgreementNavText 存在时不生效 since2.7.4
  • slogan
参数名称 参数类型 参数说明
sloganOffsetY CGFloat slogan 偏移量 Y
sloganConstraints NSArray slogan 布局对象
sloganHorizontalConstraints NSArray slogan 横屏布局, 横屏下优先级高于 sloganConstraints
sloganTextColor UIColor slogan 文字颜色
sloganFont UIFont slogan 文字 font, 默认 12
  • loading
参数名称 参数类型 参数说明
loadingConstraints NSArray loading 布局对象
loadingHorizontalConstraints NSArray 默认 loading 横屏布局,横屏下优先级高于 loadingConstraints
customLoadingViewBlock Block 类型 自定义 loading view, 当授权页点击登录按钮时回调。当此参数存在时, 默认 loading view 不会显示, 需开发者自行设计 loading view。block 内部参数为自定义 loading view 可被添加的父视图,详细用法可参见示例 demo
  • 弹窗
参数名称 参数类型 参数说明
showWindow BOOL 是否弹窗,默认 no
windowBackgroundImage UIImage 弹框内部背景图片
windowBackgroundAlpha CGFloat 弹窗外侧 透明度 0~1.0
windowCornerRadius CGFloat 弹窗圆角数值
windowConstraints NSArray 弹窗布局对象
windowHorizontalConstraints NSArray 弹窗横屏布局,横屏下优先级高于 windowConstraints
windowCloseBtnImgs NSArray 弹窗 close 按钮图片 @[普通状态图片,高亮状态图片]
windowCloseBtnConstraints NSArray 弹窗 close 按钮布局
windowCloseBtnHorizontalConstraints NSArray 弹窗 close 按钮 横屏布局, 横屏下优先级高于 windowCloseBtnConstraints

JVerification

SDK 请求授权一键登录(旧)

支持的版本

开始支持的版本 2.4.0

接口定义

  • + (void)getAuthorizationWithController:(UIViewController *)vc hide:(BOOL)hide completion:(void (^)(NSDictionary *result))completion actionBlock:(void(^)(NSInteger type, NSString *content))actionBlock

    • 接口说明:

      • 授权登录
    • 参数说明:

      • completion 登录结果
      • result 字典 获取到 token 时 key 有 operator、code、loginToken 字段,获取不到 token 是 key 为 code 和 content 字段
      • vc 当前控制器
      • hide 完成后是否自动隐藏授权页。
      • actionBlock 授权页事件触发回调。包含 type 和 content 两个参数,type 为事件类型,content 为事件描述。 type = 1, 授权页被关闭;type=2, 授权页面被拉起;type=3, 运营商协议被点击;type=4, 自定义协议 1 被点击;type=5, 自定义协议 2 被点击;type=6,checkBox 变为选中;type=7,checkBox 变为未选中;type=8, 登录按钮被点击
    • 调用示例:

[JVERIFICATIONService getAuthorizationWithController:self hide:YES completion:^(NSDictionary *result) {NSLog(@"一键登录 result:%@", result); } actionBlock:^(NSInteger type, NSString *content) {NSLog(@"一键登录 actionBlock :%ld %@", (long)type , content);}];
              [JVERIFICATIONService getAuthorizationWithController:self hide:YES completion:^(NSDictionary *result) {NSLog(@"一键登录 result:%@", result);
    } actionBlock:^(NSInteger type, NSString *content) {NSLog(@"一键登录 actionBlock :%ld %@", (long)type , content);}];

        
此代码块在浮窗中显示

SDK 请求授权一键登录(旧)

支持的版本

开始支持的版本 2.3.0

接口定义

  • + (void)getAuthorizationWithController:(UIViewController *)vc hide:(BOOL)hide completion:(void (^)(NSDictionary *result))completion

    • 接口说明:

      • 授权一键登录
    • 参数说明:

      • completion 登录结果
      • result 字典 获取到 token 时 key 有 operator、code、loginToken 字段,获取不到 token 是 key 为 code 和 content 字段
      • vc 当前控制器
      • hide 完成后是否自动隐藏授权页,默认 YES。若此字段设置为 NO,请在收到一键登录回调后调用 SDK 提供的关闭授权页面方法。
    • 调用示例:

[JVERIFICATIONService getAuthorizationWithController:self hide:YES completion:^(NSDictionary *result) {NSLog(@"一键登录 result:%@", result); }];
              [JVERIFICATIONService getAuthorizationWithController:self hide:YES completion:^(NSDictionary *result) {NSLog(@"一键登录 result:%@", result);
    }];

        
此代码块在浮窗中显示

号码认证

初始化

调用 SDK 其他流程方法前,请确保已调用过初始化,否则会返回未初始化,详情参考 SDK 初始化 API(会采集信息,建议放到同意协议后调用)。

判断网络环境是否支持

判断当前的手机网络环境是否可以使用号码认证,若网络支持,再调用号码认证 API,否则请调用其他认证方式的 API,详情参考 判断网络环境是否支持 API

获取号码认证 token(新)

支持的版本

开始支持的版本 2.2.0

接口定义

  • + (void)getToken:(NSTimeInterval)timeout completion:(void (^)(NSDictionary * result))completion;

    • 接口说明:

      • 获取手机号校验 token
    • 参数说明

      • completion 参数是字典 返回 token 、错误码等相关信息,token 有效期 1 分钟, 一次认证后失效
      • result 字典 获取到 token 时 key 有 operator、code、token 字段,获取不到 token 是 key 为 code 和 content 字段
      • timeout 超时时间(毫秒), 有效取值范围(0,10000]. 为保证获取 token 的成功率,建议设置为 3000-5000ms.
    • 调用示例:

OC [JVERIFICATIONService getToken:(NSTimeInterval)timeout completion:^(NSDictionary *result) {NSLog(@"getToken result:%@", result) //TODO: 获取 token 后相关操作 }]; Swift JVERIFICATIONService.getToken {(result) in if let result = result {if let token = result["token"] {if let code = result["code"], let op = result["operator"] {print("get token result: code = \(code), operator = \(op), token = \(token)")}}else if let code = result["code"], let content = result["content"] {print("get token result: code = \(code), content = \(content)")}} }
          OC
    [JVERIFICATIONService getToken:(NSTimeInterval)timeout completion:^(NSDictionary *result) {NSLog(@"getToken result:%@", result)
        //TODO: 获取 token 后相关操作
    }];
    
Swift    
   JVERIFICATIONService.getToken {(result) in
        if let result = result {if let token = result["token"] {if let code = result["code"], let op = result["operator"] {print("get token result: code = \(code), operator = \(op), token = \(token)")}}else if let code = result["code"], let content = result["content"] {print("get token result: code = \(code), content = \(content)")}}
    }

        
此代码块在浮窗中显示

说明:开发者可以通过 SDK 获取 token 接口的回调信息来选择验证方式,若成功获取到 token 则可以继续使用极光认证进行号码验证;若获取 token 失败,需要换用短信验证码等方式继续完成验证。

验证码

SDK 获取验证码

支持的版本

开始支持的版本 2.6.0

接口定义

  • +(void)getSMSCode:(NSString *)phoneNumber templateID:(NSString * _Nullable)templateID signID:(NSString * _Nullable)signID completionHandler:(void (^ _Nonnull)(NSDictionary * _Nonnull result) ) handler

    • 接口说明

      • 获取短信验证码,使用此功能需要在 Portal 控制台中极光短信模块添加短信签名和验证码短信模版,或者使用默认的签名或模版。详见:操作指南
      • 通过此接口获得到短信验证码后,需要调用极光验证码验证 API 来进行验证,详见:验证码验证 API
    • 参数说明

      • phoneNumber:电话号码
      • signID:短信签名 ID,如果为 nil,则为默认短信签名 ID
      • templateID:短信模板 ID,如果为 nil,则为默认短信模板 ID
      • handler :block 回调 成功的时返回的 result 字典包含 uuid ,code, msg 字段,uuid 为此次获取的唯一标识码, 失败时 result 字段仅返回 code, msg 字段
    • 调用示例

[JVERIFICATIONService getSMSCode:@"手机号" templateID:@"" signID:@"" completionHandler:^(NSDictionary * _Nonnull result) {NSLog(@"getSMSCodeWithPhoneNumber result :%@",result); }];
              [JVERIFICATIONService getSMSCode:@"手机号" templateID:@""            signID:@"" completionHandler:^(NSDictionary * _Nonnull result) {NSLog(@"getSMSCodeWithPhoneNumber result :%@",result);
      }];

        
此代码块在浮窗中显示

设置前后两次获取验证码的时间间隔

支持的版本

开始支持的版本 2.6.0

接口定义

  • + (void)setGetCodeInternal:(NSTimeInterval)intervalTime

    • 接口说明

      • 设置前后两次获取验证码的时间间隔,单位 ms 默认 30000ms,有效范围(0,300000)
    • 参数说明

      • intervalTime:时间间隔,单位是毫秒(ms)
    • 调用示例

[JVERIFICATIONService setGetCodeInternal:30000]
              [JVERIFICATIONService setGetCodeInternal:30000]

        
此代码块在浮窗中显示

行为验证

行为验证测校验

支持的版本

开始支持的版本 2.9.0

接口定义

  • + (void)getCaptchaControllerWithTimeout:(NSTimeInterval)timeout completion:(void (^)(NSDictionary *result))completion actionBlock:(void(^)(NSInteger type, NSString *content))actionBlock
    • 接口说明

      • 行为验证,第一轮安全校验。第一轮安全校验结果,需要根据第一轮安全校验结果结合后台第二轮校验,完成全流程安全校验。
    • 参数说明

      • 超时。单位毫秒,合法范围是(0,30000],默认值为 10000。此参数同时作用于拉起安全校验页面时的超时处理。
    • 调用示例

[JVERIFICATIONService getCaptchaControllerWithTimeout:3000 completion:^(NSDictionary *result) {NSCAssert([NSThread currentThread].isMainThread, @"线程管理异常"); NSLog(@"行为检 result:%@", result); [self.authorizationResult setText:result.description]; } actionBlock:^(NSInteger type, NSString *content) {NSCAssert([NSThread currentThread].isMainThread, @"线程管理异常"); NSLog(@"行为检 actionBlock :%ld %@", (long)type , content);}];
              [JVERIFICATIONService getCaptchaControllerWithTimeout:3000 completion:^(NSDictionary *result) {NSCAssert([NSThread currentThread].isMainThread, @"线程管理异常");
        NSLog(@"行为检 result:%@", result);
        [self.authorizationResult setText:result.description];
        
    } actionBlock:^(NSInteger type, NSString *content) {NSCAssert([NSThread currentThread].isMainThread, @"线程管理异常");
        NSLog(@"行为检 actionBlock :%ld %@", (long)type , content);}];

        
此代码块在浮窗中显示

自定义行为验证参数

支持的版本

开始支持的版本 2.9.0

接口定义

  • + (void)customCaptchaWithConfig:(JVCaptchaConfig *)captchaConfig

    • 接口说明

      • 自定义行为验证参数。
    • 参数说明

      • 自定义 UI 设置。仅使用 JVCaptchaConfig 类型对象。
    • 调用示例

JVCaptchaConfig *config = [[JVCaptchaConfig alloc] init]; config.captchaDisplayStyle = JVDisplayStyleBottom; config.captchaProtocol = @"http"; [JVERIFICATIONService customCaptchaWithConfig:config];
              JVCaptchaConfig *config = [[JVCaptchaConfig alloc] init];
    config.captchaDisplayStyle = JVDisplayStyleBottom;
    config.captchaProtocol = @"http";
    [JVERIFICATIONService customCaptchaWithConfig:config];

        
此代码块在浮窗中显示

行为验证配置类

行为验证的校验界面 UI 配置类,JVCaptchaConfig 类。

参数名称 参数类型 参数说明
captchaScene JVCaptchaScene 使用场景,默认 JVCaptchaSceneRandom
captchaProtocol NSString 远程访问静态资源时的协议,默认 @“https”
captchaStaticServers NSArray<NSString * > 静态服务地址,默认为空
captchaApiServers NSArray<NSString *> 接口服务地址,默认为空
captchaUserInterfaceStyle JVUserInterfaceStyle 界面样式,默认 JVUserInterfaceStyleLight
captchaDisplayStyle JVDisplayStyle 界面的展示方式,默认 JVDisplayStyleCenter
captchaBackgroundColor UIColor 背景颜色,默认透明
captchaBackgroundUserInteractionEnable BOOL 点击背景的交互,默认开启
captchaLanguage NSString 语言,默认跟随系统
captchaAdditionalParameter NSMutableDictionary 额外的参数, 默认为空。参数将被组装后提交到验证服务

JVUserInterfaceStyle 枚举

行为验证 - 验证界面样式(User interface style) 2.9.0+ 生效。

枚举值 枚举说明
JVUserInterfaceStyleSystem 跟随系统样式(Follow system)
JVUserInterfaceStyleLight 普通样式(Light)
JVUserInterfaceStyleDark 暗黑样式(Dark)
JVUserInterfaceStyleDefault 默认样式(Default)

JVDisplayStyle 枚举

行为验证 - 验证展示方式(Display style) 2.9.0+ 生效。

枚举值 枚举说明
JVDisplayStyleCenter 居中展示(Center)
JVDisplayStyleBottom 底部展示(Bottom)
JVDisplayStyleDefault 默认展示(Default)
文档内容是否对您有帮助?

Copyright 2011-2022, jiguang.cn, All Rights Reserved. 粤ICP备12056275号-13 深圳市和讯华谷信息技术有限公司

在文档中心打开