[Как я могу предоставить имя пользователя, зарегистрироваться и войти, когда у меня есть этот код] [1]
импорт UIKit
импорт Firebase
импорт FirebaseAuth
class SignUpController: UIViewController {
@IBOutlet weak var passwordTextField: UITextField!
@IBOutlet weak var usernameTextField: UITextField!
@IBOutlet weak var emailTextField: UITextField!
@IBAction func ContinueButton(_ sender: UIButton) {
if emailTextField.text == "" {
let alertController = UIAlertController(title: "Error",message: "Please enert your emiail and password", preferredStyle: .alert)
let defaultAction = UIAlertAction(title: "OK", style: .cancel, handler: nil)
present(alertController, animated: true, completion: nil)
}
else {
Auth.auth().createUser(withEmail: emailTextField.text!, password: passwordTextField.text!) { (user, error) in
if error == nil {
print("You have successfully signed up")
let vc = self.storyboard?.instantiateViewController(withIdentifier: "HomeController")
self.present(vc!, animated: true, completion: nil)
} 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)
}
}
}
}