天天看點

阿裡雲本機一鍵登入內建

阿裡雲一鍵登入內建

//本機号碼一鍵登入

@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 {

}