阿里云本机一键登录集成

阿里云本机一键登录集成,第1张

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

                @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也有很多问题但是比文档更贴近实际。
阿里云本机一键登录授权页面修改

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/997117.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-21
下一篇 2022-05-21

发表评论

登录后才能评论

评论列表(0条)

保存