我正在构建一个带有iOS应用程序身份验证的UI界面。我离原先的位置已经走了很长一段路,但是我无法克服这个错误。我不明白自己的编译错误。请看一下,如果可以的话,请帮帮我。
import UIKit
import Firebase
class SignUpViewController: UIViewController, UITextFieldDelegate
{
@IBOutlet weak var email: UITextField!
@IBOutlet weak var password: UITextField!
@IBOutlet weak var passwordConfirm: UITextField!
@IBOutlet weak var signUpButton: UIButton!
override func viewDidLoad() {
super.viewDidLoad()
email.delegate = self
password.delegate = self
passwordConfirm.delegate = self
}
@IBAction func signUpAction(_ sender: UIButton) {
if password.text !=
passwordConfirm.text{
let alertController = UIAlertController(title: "Password Incorrect", message: "Please re-type password", preferredStyle: .alert)
let defaultAction = UIAlertAction(title: "OK", style: .cancel, handler: nil)
alertController.addAction(defaultAction)
self.present(alertController, animated: true, completion: nil)
}
else{
Auth.auth().createUser(withEmail: email.text!, password: password.text!){ (user, error) in
if error == nil {
self.performSegue(withIdentifier: "signupToHome", sender: self)
}
else{
let alertController = UIAlertController(title: "Error", message: error?.localizedDescription, preferredStyle: .alert)
let defaultAction = UIAlertAction(title: "OK", style: .cancel, handler: nil)
alertController.addAction(defaultAction)
self.present(alertController, animated: true, completion: nil)
}
}
}
}
func textFieldShouldReturn(_ textField: UITextField) -> Bool { //delegate method
textField.resignFirstResponder()
return true
}
}
目标是,然后在我的Firebase控制台中创建新用户后,接受来自email.text和password.text的用户输入,并进入主屏幕。
答案 0 :(得分:0)
Firebase拥有自己的电子邮件验证,类似于“ abc@somedomain.com”,因此您需要以其他方式传递电子邮件地址,否则它将不断抛出此错误。