繁体   English   中英

Firebase电话验证

[英]Firebase Phone Auth

我正在尝试将Firebase Phone Auth添加到我在XCode中制作的应用程序中。 但是,我在使用firebase文档的第3步以及之后的所有操作时遇到了麻烦。

我不知道我的代码应该去哪里。 我已经尝试了其中的一些,并附上了到目前为止所做工作的图像 请帮忙。

谢谢。

好的,代码似乎正确。 现在,您必须添加另一个文本字段,用户可以在其中添加来自SMS的验证码。

在添加代码后,由用户触发的新方法中,您必须像示例代码中一样设置FIRAuthCredential:

FIRAuthCredential *credential = [[FIRPhoneAuthProvider provider]
credentialWithVerificationID:verificationID
            verificationCode:newTextField.text!];

然后使用以下命令登录:

[[FIRAuth auth] signInAndRetrieveDataWithCredential:credential
                                     completion:^(FIRAuthDataResult * _Nullable authResult,
                                                  NSError * _Nullable error) {
 if (error) {
   // ...
   return;
 }
 // User successfully signed in. Get user data from the FIRUser object
 if (authResult == nil) { return; }
 FIRUser *user = authResult.user;
 // ...
}];

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM