Ios 设备上未验证电子邮件(Firebase)

Ios 设备上未验证电子邮件(Firebase),ios,swift,firebase,firebase-authentication,Ios,Swift,Firebase,Firebase Authentication,我正在尝试注册一个用户并验证他们的电子邮件。我已经这样做了,并在电子邮件中验证了它,但在Auth.Auth().currentUser.isEmailVerified上进行了验证 if (Auth.auth().currentUser?.isEmailVerified)! { // present another vc } else { print("not verified yet") //Always prints that } 以下

我正在尝试注册一个用户并验证他们的电子邮件。我已经这样做了,并在电子邮件中验证了它,但在Auth.Auth().currentUser.isEmailVerified上进行了验证

    if (Auth.auth().currentUser?.isEmailVerified)! {
        // present another vc
    } else {
        print("not verified yet") //Always prints that
    }
以下是我的sendVerificationEmail功能:

if let user = Auth.auth().currentUser {
            user.sendEmailVerification(completion: { (error) in
            if let error = error {
                debugPrint(error)
                return
            }
                print("Sent VerificationMail")
        })
    } else {
        print("no user logged in")
    }
我在这里注册用户:

func registrateUser(email: String, password: String, completion: @escaping (Bool) -> Void) {
    Auth.auth().createUser(withEmail: email, password: password) { (result, error) in
        if let error = error {
            debugPrint(error)
            completion(false)
            return
        }
        result?.user.sendEmailVerification(completion: { (error) in
            if let error = error {
                debugPrint(error)
                completion(false)
                return
            }
            completion(true)
        })
    }
}

在检查电子邮件是否已验证之前,您需要重新加载用户配置文件

使用以下代码:

Auth.auth().currentUser?.reload(completion: { (error) in
    guard error == nil else {
        // handle error
        print(error!.localizedDescription)
        return
    }

    // your code below
    if (Auth.auth().currentUser?.isEmailVerified)! {
        // present another vc
    } else {
        print("not verified yet") //Always prints that
    }
})