Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/19.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 为什么不是';my sendEmailVerification(在更新电子邮件之前)函数是否总是返回错误?_Ios_Swift_Xcode_Firebase_Google Cloud Firestore - Fatal编程技术网

Ios 为什么不是';my sendEmailVerification(在更新电子邮件之前)函数是否总是返回错误?

Ios 为什么不是';my sendEmailVerification(在更新电子邮件之前)函数是否总是返回错误?,ios,swift,xcode,firebase,google-cloud-firestore,Ios,Swift,Xcode,Firebase,Google Cloud Firestore,我正在尝试在更新用户的电子邮件地址之前发送电子邮件验证电子邮件。然而,目前这种做法并不奏效。我不知道为什么。我尝试过各种不同的方法。我想这可能是因为我在user?.sendEmailVerification(在更新电子邮件之前:)后面放了字符串,但我不确定。任何帮助都将不胜感激。我已经在这上面呆了一段时间了 @IBAction func setEmailIsTapped(_ sender: Any) { let error = validateEmailField()

我正在尝试在更新用户的电子邮件地址之前发送电子邮件验证电子邮件。然而,目前这种做法并不奏效。我不知道为什么。我尝试过各种不同的方法。我想这可能是因为我在
user?.sendEmailVerification(在更新电子邮件之前:)
后面放了字符串,但我不确定。任何帮助都将不胜感激。我已经在这上面呆了一段时间了

@IBAction func setEmailIsTapped(_ sender: Any) {
            let error = validateEmailField()
            if error != nil {
                print(error!) //Needs a Label
            }
            let db = Firestore.firestore()
                let userID = Auth.auth().currentUser?.uid
             let emailSearch = db.collection("users")
                let email = emailTextField.text!
            let query = emailSearch.whereField("email", isEqualTo: email).getDocuments { (snapshot, error) in
                 if let error = error {
                    print("An error was encountered")
                 } else {
                     if snapshot!.isEmpty {
                        let user = Auth.auth().currentUser
                        user?.sendEmailVerification(beforeUpdatingEmail: self.emailTextField.placeholder!, completion: { (error) in
                            if error != nil {
                                print("Error sending update email")
                            } else {
                                print("Success")
                            }
                        })
                    }
                }

        }
        }

您应该将
电子邮件
而不是
UITextField
占位符
作为参数传递,如下所示:

user?.sendEmailVerification(beforeUpdatingEmail: email, completion: { (error) in
    if error != nil {
        print("Error sending update email")
    } else {
        print("Success")
    }
})

您应该将
电子邮件
而不是
UITextField
占位符
作为参数传递,如下所示:

user?.sendEmailVerification(beforeUpdatingEmail: email, completion: { (error) in
    if error != nil {
        print("Error sending update email")
    } else {
        print("Success")
    }
})

嗨,谢谢你的回复。我试过这样做,但它仍然返回一个错误,而不是成功。你还有什么想法吗?嗨,谢谢你的回复。我试过这样做,但它仍然返回一个错误,而不是成功。您还有什么想法吗?您的代码与此处示例中的
Auth.Auth().currentUser?.sendEmailVerification{(错误)中的
Auth.Auth()