Firebase Phone Auth

问题描述 投票:1回答:1

我正在尝试将Firebase Phone Auth添加到我在XCode中创建的应用程序中。但是,我在firebase documentation的第3步和之后的一切都遇到了麻烦。

我不明白我的代码应该去哪里。我已经尝试了一些,我附上了迄今为止我所做的image。请帮忙。

谢谢。

ios xcode firebase firebase-authentication
1个回答
0
投票

好的,代码似乎是正确的。现在,您必须添加另一个文本字段,用户可以在其中添加从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;
 // ...
}];
© www.soinside.com 2019 - 2024. All rights reserved.