1

我有一个错误,当我删除我的用户信息时,没有调用完成块。我已经看到有关完成块的问题的答案,但是我的问题仍然存在。我能够成功地从我的数据库中删除用户,并且在删除之前我还重新验证了用户。这是我的代码:

let ref = FIRDatabase.database().reference()

let deleteUserFromCurrentSchool = ref.child("schoolOrWorkAddress").child(self.currentUser.schoolOrWorkAddress).child(self.currentUser.id)
deleteUserFromCurrentSchool.removeValue()

let deleteUserFromUserNode = ref.child("users").child(self.currentUser.id)
deleteUserFromUserNode.removeValue()

let currentUserToDelete = FIRAuth.auth()?.currentUser

if currentUserToDelete != nil {
    currentUserToDelete?.delete(completion: { (error) in
        if error != nil {
            ProgressHUD.showError(Constants.ProgressMessages.errorMessage)
        } else {
            ProgressHUD.showSuccess("Account Deleted. Thanks for using ZipShare!")
            let vc = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "Home")
            self.present(vc, animated: true, completion: nil)
        }
    })
}

正如我所说,用户正在被删除。但是,完成块之后的代码没有被调用。我真的不知道为什么,任何帮助将不胜感激!

PS:这里要清楚的是没有被调用的代码:

if error != nil {
    ProgressHUD.showError(Constants.ProgressMessages.errorMessage)
} else {
    ProgressHUD.showSuccess("Account Deleted. Thanks for using ZipShare!")
    let vc = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "Home")
    self.present(vc, animated: true, completion: nil)
}
4

0 回答 0