阿里云本机一键登录授权页面修改

简介: 阿里云本机一键登录授权页面修改

阿里云的一键登录的集成文档就是一个大大的坑,demo是也是一个小坑。

文档完全对不上授权SDK,demo你用了运行没有问题,但是你把它的模拟网络请求后台token请求接入工程使用就闪退了,当然它毕竟是模拟。然而文档只是说登录授权页面可以修改,但是无论是文档还是demo都没有具体说明怎么修改授权页面,你说坑不坑。我琢磨了两天才从SDK头文件里找到修改授权页面的方法。

注册请求

    NSString *authSDKInfo = [[NSUserDefaults standardUserDefaults] objectForKey:PNSATAUTHSDKINFOKEY];
    if (!authSDKInfo || authSDKInfo.length == 0) {
        authSDKInfo = PNSATAUTHSDKINFO;
    }
    [PNSHttpsManager requestATAuthSDKInfo:^(BOOL isSuccess, NSString * _Nonnull authSDKInfo) {
        if (isSuccess) {
            [[NSUserDefaults standardUserDefaults] setObject:authSDKInfo forKey:PNSATAUTHSDKINFOKEY];
        }
    }];
    [[TXCommonHandler sharedInstance] setAuthSDKInfo:authSDKInfo
                                            complete:^(NSDictionary * _Nonnull resultDic) {
        NSLog(@"设置秘钥结果:%@", resultDic);
    }];

这个是调用授权的代码:

                @weakify(self);
                //环境检查,异步返回
                [[TXCommonHandler sharedInstance] checkEnvAvailableWithAuthType:PNSAuthTypeLoginToken
                                                                       complete:^(NSDictionary * _Nullable resultDic) {
                    @strongify(self);
                    NSLog(@"环境检查返回:%@", resultDic);
//                    UINavigationController *navigationController = self.navigationController;
                    self.isCanUseOneKeyLogin = [PNSCodeSuccess isEqualToString:[resultDic objectForKey:@"resultCode"]];
                    DYMobileAuthEntity *mobileAuthEntity1 = [DYMobileAuthEntity mj_objectWithKeyValues:resultDic];

                    if (self.isCanUseOneKeyLogin == YES) {
                        TXCustomModel *model = [PNSBuildModelUtils buildModelWithButton1Title:@"切换其他手机号"
                                                                               target1:self
                                                                             selector1:@selector(gotoVerificationCodeLoginPage)];
                        
                        
//                        TXCustomModel *model = [PNSBuildModelUtils buildModelWithStyle:PNSBuildModelStylePortrait
//                                                                          button1Title:@"切换其他手机号"
//                                                                               target1:self
//                                                                             selector1:@selector(gotoSmsControllerAndShowNavBar)
//                                                                          button2Title:@""
//                                                                               target2:self
//                                                                             selector2:@selector(gotoSmsControllerAndHiddenNavBar)];
                        model.backgroundColor = BGColorHex(FAFAFA);
                        model.navColor = BGColorHex(FAFAFA);
                        NSString *textString = @"";
                        model.navTitle = [[NSAttributedString alloc]initWithString:textString attributes:@{NSForegroundColorAttributeName:DEFAULT_TITLE_FRONT_COLOR,NSFontAttributeName:BGMediumFont(22)}];
                        model.navBackImage = [UIImage imageNamed:@"navbar_icon_back"];
                        self.customModel = model;
//                        //设置不起作用
//                        model.navTitleFrameBlock = ^CGRect(CGSize screenSize, CGSize superViewSize, CGRect frame) {
//                            @strongify(self);
//
//                            return CGRectMake(frame.origin.x, 15, frame.size.width, frame.size.height);
//                        };
//                        model.sloganTopOffetY = 158.0;
                        model.sloganFrameBlock = ^CGRect(CGSize screenSize, CGSize superViewSize, CGRect frame) {
                            return CGRectMake(frame.origin.x, 158.0, frame.size.width, frame.size.height);
                        };
                        model.numberColor = DEFAULT_TITLE_FRONT_COLOR;
                        model.numberFont = BGBoldFont(25);
//                        model.numberTopOffetY = 120.0;
                        model.numberFrameBlock = ^CGRect(CGSize screenSize, CGSize superViewSize, CGRect frame) {
                            return CGRectMake(frame.origin.x, 120.0, frame.size.width, frame.size.height);
                        };
                        model.loginBtnText = [[NSAttributedString alloc]initWithString:@"同意并协助登录" attributes:@{NSForegroundColorAttributeName:[UIColor whiteColor],NSFontAttributeName:BGMediumFont(15)}];
                        UIImage *loginImage = [UIImage imageNamed:@"icon_login"];
                        model.loginBtnBgImgs = @[loginImage,loginImage,loginImage];
//                        model.loginBtnTopOffetY = 212.0;
//                        model.loginBtnHeight = 45.0;
//                        model.loginBtnLRPadding = (FULL_WIDTH - 295)/2.0;
                        model.loginBtnFrameBlock = ^CGRect(CGSize screenSize, CGSize superViewSize, CGRect frame) {
                            return CGRectMake((FULL_WIDTH - 295)/2.0, 212.0, 295, 45);
                        };
                        
                        [[TXCommonHandler sharedInstance] getLoginTokenWithTimeout:3.0 controller:self model:model complete:^(NSDictionary * _Nonnull resultDic) {
                            @strongify(self);
                            NSLog(@"为后面授权页拉起加个速,加速结果:%@", resultDic);
                            DYMobileAuthEntity *mobileAuthEntity = [DYMobileAuthEntity mj_objectWithKeyValues:resultDic];
                            if(mobileAuthEntity && [mobileAuthEntity isKindOfClass:[DYMobileAuthEntity class]] && !isCommonUnitEmptyString(mobileAuthEntity.resultCode))
                            {
                                if([PNSCodeSuccess isEqualToString:mobileAuthEntity.resultCode])
                                {
                                    self.model.accessToken = mobileAuthEntity.token;
                                    [self excuteMemberAccountLoginByTelCommand];
                                }
                                else if([PNSCodeLoginControllerClickLoginBtn isEqualToString:mobileAuthEntity.resultCode] && !(mobileAuthEntity.isChecked))
                                {
                                    [[BITNoticeView currentNotice] showErrorNotice:@"请同意认证服务条款、龙莱用户协议以及隐私政策"];
                                }
                            }

                        }];

修改授权页面的协议增加按钮和标签:

+ (TXCustomModel *)buildModelWithButton1Title:(NSString *)button1Title
                                      target1:(id)target1
                                    selector1:(SEL)selector1
{
    TXCustomModel *model = [[TXCustomModel alloc] init];
    model.supportedInterfaceOrientations = UIInterfaceOrientationMaskPortrait;
//    model.navColor = [UIColor orangeColor];
//    NSDictionary *attributes = @{
//        NSForegroundColorAttributeName : [UIColor whiteColor],
//        NSFontAttributeName : [UIFont systemFontOfSize:20.0]
//    };
//    model.navTitle = [[NSAttributedString alloc] initWithString:@"一键登录" attributes:attributes];
//    model.navBackImage = [UIImage imageNamed:@"icon_nav_back_light"];
//    model.logoImage = [UIImage imageNamed:@"taobao"];
//    model.changeBtnIsHidden = YES;

    model.checkBoxImages = @[[UIImage imageNamed:@"icon_select_agreement"],[UIImage imageNamed:@"icon_select_agreement_select"]];
    model.privacyOne = @[@"龙莱用户协议", @"https://www.taobao.com"];
    model.privacyTwo = @[@"隐私政策", @"https://www.baidu.com/"];
    model.privacyConectTexts = @[@"、", @",", @"以及"];
    
    model.privacyColors = @[DEFAULT_TITLE_SUPER_FRONT_COLOR, BGColorHex(64B7FF)];
    model.checkBoxWH = 15.0;
    model.privacyPreText = @"使用手机号码登录并同意";
    model.privacyNavBackImage = [UIImage imageNamed:@"navbar_icon_back"];
    
    UILabel *titleLabel = [[UILabel alloc] init];
    titleLabel.backgroundColor = [UIColor clearColor];
    titleLabel.text = @"本机号码一键登录";
    titleLabel.textColor = DEFAULT_TITLE_FRONT_COLOR;
    titleLabel.font = BGMediumFont(22);
    titleLabel.textAlignment = NSTextAlignmentCenter;
    
    UIButton *button1 = [UIButton buttonWithType:UIButtonTypeSystem];
    [button1 setTitle:button1Title forState:UIControlStateNormal];
    [button1 addTarget:target1 action:selector1 forControlEvents:UIControlEventTouchUpInside];
    [button1.titleLabel setFont:[UIFont systemFontOfSize:14]];
    [button1 setTitleColor:DEFAULT_TITLE_FRONT_COLOR forState:UIControlStateNormal];
    button1.backgroundColor =  [UIColor clearColor];
    
    
    model.customViewBlock = ^(UIView * _Nonnull superCustomView) {
        [superCustomView addSubview:titleLabel];
        [superCustomView addSubview:button1];
    };
    model.customViewLayoutBlock = ^(CGSize screenSize, CGRect contentViewFrame, CGRect navFrame, CGRect titleBarFrame, CGRect logoFrame, CGRect sloganFrame, CGRect numberFrame, CGRect loginFrame, CGRect changeBtnFrame, CGRect privacyFrame) {
        titleLabel.frame = CGRectMake(0,
                                   15,
                                   screenSize.width,
                                   22);
        button1.frame = CGRectMake(0,
                                   285,
                                   screenSize.width,
                                   14);
        
    };
    model.changeBtnIsHidden = YES;
    return model;
}
目录
相关文章
|
移动开发 缓存 监控
面试官:本机号码一键登录,是怎么实现的?
面试官:本机号码一键登录,是怎么实现的?
3651 0
面试官:本机号码一键登录,是怎么实现的?
|
Android开发
Android 自带的字体库、字体样式
Android 自带的字体库、字体样式
2664 0
Android 自带的字体库、字体样式
|
6月前
|
存储 人工智能 弹性计算
阿里云云小站功能详解与使用教程
阿里云云小站是官方云产品优惠聚合页,涵盖云服务器(轻量/ECS/e实例)、百炼大模型、Token Plan、JVS Claw、Qoder编程、数据库、存储及安全等精选资源,一站式满足新手入门、AI开发与企业上云需求。
|
数据安全/隐私保护
APP备案使用证书查看公钥和md5
【10月更文挑战第19天】首先有了一个证书,文件后缀是keystore
3792 13
APP备案使用证书查看公钥和md5
|
网络协议 图形学 Windows
unity获取本机IP地址
在 Unity 中,通过 .NET 框架的 System.Net 命名空间提供的 Dns 和 NetworkInterface 类,可以获取本机的 IPv4 和 IPv6 地址。使用 Dns.GetHostEntry 方法获取主机信息,并根据地址族(AddressFamily.InterNetwork 或 AddressFamily.InterNetworkV6)筛选出相应的 IP 地址。代码示例展示了如何分别获取 IPv4 和 IPv6 地址并输出到控制台。
1039 10
|
存储 小程序 Java
【小程序分包】小程序包大于2M,来这教你分包啊
本文介绍了如何通过分包解决uniapp小程序包体积过大的问题。由于版本升级导致包体积超过2M,即使压缩静态资源也无法满足发布要求。文章详细讲解了分包的原因、步骤及注意事项,并提供了实操示例,帮助读者理解并实现小程序分包,从而减小主包大小
1816 2
【小程序分包】小程序包大于2M,来这教你分包啊
|
存储 人工智能 Java
Neo4j从入门到精通:打造高效知识图谱数据库 | AI应用开发
在大数据和人工智能时代,知识图谱作为一种高效的数据表示和查询方式,逐渐受到广泛关注。本文从入门到精通,详细介绍知识图谱及其存储工具Neo4j,涵盖知识图谱的介绍、Neo4j的特点、安装步骤、使用方法(创建、查询)及Cypher查询语言的详细讲解。通过本文,读者将全面了解如何利用Neo4j处理复杂关系数据。【10月更文挑战第14天】
2491 6
|
JSON 达摩院 Java
大模型时代下的文档智能 | 文档解析(大模型版)
文档智能(Document Mind)是基于阿里巴巴达摩院技术打造的多模态文档识别与理解引擎,提供通用文档智能、行业文档智能和文档自学习能力,满足各类智能文档处理需求。尤其在企业中,它能有效处理文本、图片、扫描件等多种非结构化文档,释放数据价值。本文将介绍文档智能的应用场景、产品架构及其核心功能——文档解析(大模型版),并展示其在线体验与API接口调用方法。