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

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

阿里云的一键登录的集成文档就是一个大大的坑,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;
}
目录
相关文章
|
10月前
|
SQL Java
如何使用阿里云短信服务实现登录页面,手机验证码登录?1
如何使用阿里云短信服务实现登录页面,手机验证码登录?
293 0
|
1月前
|
弹性计算 Windows
使用阿里云服务器登录雾锁王国后,游戏创建失败怎么办
使用阿里云服务器登录雾锁王国后,游戏创建失败时,请更新游戏并重启游戏进程。
317 3
|
23天前
|
开发工具 iOS开发
阿里云本机一键登录集成
阿里云本机一键登录集成
34 0
|
1月前
|
关系型数据库 Linux 数据库
阿里云数据库镜像如何登录账号
阿里云数据库镜像是一种方便快捷的方式,使得开发者可以在自己的本地电脑上进行数据库的开发和测试,而无需在云端进行复杂的环境配置。本文将详细讲解如何通过阿里云数据库镜像登录账号。一、准备环境在开始之前,你需要确保已经安装了阿里云数据库镜像,并在本地电脑上成功配置了数据库环境。如果你还没有安装,可以参考阿里云提供的安装。
|
1月前
|
敏捷开发 Devops 测试技术
云效产品使用常见问题之不知道每次登录是否会记录在阿里云账号的登录日志中如何解决
云效作为一款全面覆盖研发全生命周期管理的云端效能平台,致力于帮助企业实现高效协同、敏捷研发和持续交付。本合集收集整理了用户在使用云效过程中遇到的常见问题,问题涉及项目创建与管理、需求规划与迭代、代码托管与版本控制、自动化测试、持续集成与发布等方面。
|
1月前
|
存储 DataWorks Kubernetes
阿里云cam授权案例
以下是内容摘要: 1. 阿里云OSS自定义策略允许全权访问`dc-odsopr`及其所有内容。 2. Dataworks授权文档详情见[此处](https://help.aliyun.com/document_detail/74302.html)。 3. 日志权限策略涵盖多种日志操作,如获取和管理项目、作业、日志存储等,限定于`cn-shenzhen`区域的`k8s`项目。 4. AliKafka权限包括实例、主题的管理,消息操作及部署、ACL、用户管理等。 5. OSS策略允许上传对象至`sz-creative-system-test-public`存储空间。
108 5
|
1月前
|
存储 安全
阿里云网盘与相册问题之账户登录不上如何解决
阿里云网盘与相册是阿里云提供的云存储服务,用户可以安全便捷地存储和管理个人文件、照片等数据;本合集将介绍如何使用阿里云网盘和相册服务,包括文件上传、同步、分享,以及处理常见使用问题的技巧。
|
1月前
|
存储 缓存 安全
阿里云网盘与相册问题之如何解除限制境外IP登录
阿里云网盘与相册是阿里云提供的云存储服务,用户可以安全便捷地存储和管理个人文件、照片等数据;本合集将介绍如何使用阿里云网盘和相册服务,包括文件上传、同步、分享,以及处理常见使用问题的技巧。
|
10月前
|
JavaScript 前端开发
如何使用阿里云短信服务实现登录页面,手机验证码登录?2
如何使用阿里云短信服务实现登录页面,手机验证码登录?
204 0
|
18天前
|
存储 固态存储 安全
阿里云4核CPU云服务器价格参考,最新收费标准和活动价格
阿里云4核CPU云服务器多少钱?阿里云服务器核数是指虚拟出来的CPU处理器的核心数量,准确来讲应该是vCPU。CPU核心数的大小代表了云服务器的运算能力,CPU越高,云服务器的性能越好。阿里云服务器1核CPU就是一个超线程,2核CPU2个超线程,4核CPU4个超线程,这样云服务器可以同时处理多个任务,计算性能更强。如果网站流程较小,少量图片展示的企业网站,建议选择2核及以上CPU;如果网站流量较大,动态页面比较多,有视频等,建议选择4核、8核以上CPU。
阿里云4核CPU云服务器价格参考,最新收费标准和活动价格

热门文章

最新文章