阿里云本机一键登录集成

本文档详细介绍了如何在iOS应用中集成阿里云的一键登录功能。首先进行环境检查,然后根据结果展示相应操作,如切换其他手机号或进行登录。在用户授权后,调用后台接口获取手机号和token,实现快速登录。若无SIM卡,则引导用户通过其他方式登录。需要注意的是,阿里云的SDK文档可能未及时更新,建议参考示例代码进行实际集成。
摘要由CSDN通过智能技术生成

阿里云一键登录集成
//本机号码一键登录

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

                    if (self.isCanUseOneKeyLogin == YES) {
                        TXCustomModel *model = [PNSBuildModelUtils buildModelWithStyle:PNSBuildModelStylePortrait
                                                                          button1Title:@"切换其他手机号"
                                                                               target1:self
                                                                             selector1:@selector(gotoSmsControllerAndShowNavBar)
                                                                          button2Title:@""
                                                                               target2:self
                                                                             selector2:@selector(gotoSmsControllerAndHiddenNavBar)];
                        [[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) && [PNSCodeSuccess isEqualToString:mobileAuthEntity.resultCode])
                            {
                                self.model.accessToken = mobileAuthEntity.token;
                                [self excuteMemberAccountLoginByTelCommand];
                            }

                        }];
                    }
                    else if(!isCommonUnitEmptyString(mobileAuthEntity1.resultCode) && [mobileAuthEntity1.resultCode isEqualToString:@"600007"])
                    {
                        //无SIM卡
                        [BITRouter openURL:@"gb://passwordLoginViewController"];
                    }
                }];

调用后台本机号码登录获取手机号和后台token

- (void)excuteMemberAccountLoginByTelCommand
{
    @weakify(self);
    [[self.viewModel.memberAccountLoginByTelCommand execute:self.model]subscribeNext:^(id result) {
        @strongify(self);
        [[TXCommonHandler sharedInstance] cancelLoginVCAnimated:NO complete:^{
            @strongify(self);
            [self backPage];
        }];
    } error:^(NSError *error) {
        @strongify(self);
    }];
}

切换其他手机号

- (void)gotoSmsControllerAndShowNavBar {
    @weakify(self);
    [[TXCommonHandler sharedInstance] cancelLoginVCAnimated:NO complete:^{
        @strongify(self);
        [BITRouter openURL:@"gb://passwordLoginViewController"];
    }];
}


- (void)gotoSmsControllerAndHiddenNavBar {

}

集成具体参考《iOS客户端接入》。阿里云这个文档没有根据最新的SDK进行实时更新,许多导入库的细节没有写,具体参照里面的demo进行接入。虽然demo也有很多问题但是比文档更贴近实际。
阿里云本机一键登录授权页面修改

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值