简体   繁体   English

Firebase电话验证

[英]Firebase Phone Auth

I'm trying to add Firebase Phone Auth to an app that I'm making in XCode. 我正在尝试将Firebase Phone Auth添加到我在XCode中制作的应用程序中。 However, I'm having trouble with steps 3 of the firebase documentation and everything after that. 但是,我在使用firebase文档的第3步以及之后的所有操作时遇到了麻烦。

I don't understand where my code is supposed to go. 我不知道我的代码应该去哪里。 I try some of it already and I attached the image of what I have done so far. 我已经尝试了其中的一些,并附上了到目前为止所做工作的图像 Please help. 请帮忙。

Thank you. 谢谢。

Ok, the code seems right. 好的,代码似乎正确。 Now you must add another textfield where the user can add the verification code arrived from the SMS. 现在,您必须添加另一个文本字段,用户可以在其中添加来自SMS的验证码。

In a new method triggered by the user after adding the code you must set a FIRAuthCredential like in the code of the example: 在添加代码后,由用户触发的新方法中,您必须像示例代码中一样设置FIRAuthCredential:

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

And then do the signin with: 然后使用以下命令登录:

[[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