Firebase .isEmailVerified返回错误

时间:2018-08-20 07:21:53

标签: ios firebase firebase-authentication

我无法让用户验证功能正常工作,因为它不断返回“ AuthDataResult”,没有成员“ isEmailVerified”错误。

有人愿意提供帮助或建议如何解决该问题吗?

class LoginViewController: UIViewController, UITextFieldDelegate {

@IBOutlet var username: UITextField!
@IBOutlet var password: UITextField!

var userID = Auth.auth().currentUser?.uid

override func viewDidLoad() {
    super.viewDidLoad()
    // Do any additional setup after loading the view.

    username.delegate = self
    password.delegate = self
    self.hideKeyboardwhenTappedAround()

}

@IBAction func loginButtonTapped(_ sender: Any) {
    Auth.auth().signIn(withEmail: username.text!, password: password.text!) { (user, error) in
        if error != nil {
            let loginerrorAlert = UIAlertController(title: "Login Error", message: "Please try again", preferredStyle: .alert)
            loginerrorAlert.addAction(UIAlertAction(title: "OK", style: .default, handler: nil))
            self.present(loginerrorAlert, animated: true, completion: nil)
            return
        }

        if user!.isEmailVerified { //value of type 'AuthDataResult' has no member 'isEmailVerified'
            //Take user to Firebase Realtime Database
            self.performSegue(withIdentifier: "userLoggedIn", sender: self)
        } else {
            let notverifiedAlert = UIAlertController(title: "Not verified", message: "Your account is pending verification. Please check your email and verify your account.", preferredStyle: .alert)
            notverifiedAlert.addAction(UIAlertAction(title: "OK", style: .default, handler: nil))
            self.present(notverifiedAlert, animated: true, completion: nil)
            do{
                try Auth.auth().signOut()
            } catch {
                // HANDLE ERROR
            }
        }
    }
}

0 个答案:

没有答案