gpt4 book ai didi

swift - Firebase 和 Swift 的重置密码问题

转载 作者:可可西里 更新时间:2023-11-01 00:51:20 24 4
gpt4 key购买 nike

在 Firebase 更新了他们的后端之后,我遇到了重设密码的问题。由于某种原因,该应用程序崩溃了(即使它发送了带有重置密码的电子邮件)。这是我得到的控制台错误:

2016-06-04 12:32:21.883 NewApp[47459:27055361] *** Assertion failure in -[UIKeyboardTaskQueue waitUntilAllTasksAreFinished], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit_Sim/UIKit-3512.60.7/Keyboard/UIKeyboardTaskQueue.m:386
2016-06-04 12:32:21.890 NewApp[47459:27055361] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[UIKeyboardTaskQueue waitUntilAllTasksAreFinished] may only be called from the main thread.'
libc++abi.dylib: terminating with uncaught exception of type NSException

在 ResetPasswordVC 中,我有以下内容:

 @IBAction func resetPasswordTapped(sender: ButtonWhite) {

SVProgressHUD.showWithStatus("Please, wait...")
SVProgressHUD.setDefaultMaskType(.Gradient)

let email = emailTextField.text

if email != "" {

FIRAuth.auth()?.sendPasswordResetWithEmail(email!, completion: { (error) in

if error != nil {

// Error - Unidentified Email
SVProgressHUD.dismiss()
showAlert(title: "Unidentified Email Address", msg: "Please, re-enter the email you have registered with.", actionButton: "OK", viewController: self)

} else {

// Success - Sent recovery email

SVProgressHUD.dismiss()

let alertController = UIAlertController(title: "Email Sent", message: "An email has been sent. Please, check your email now.", preferredStyle: .Alert)
alertController.addAction(UIAlertAction(title: "OK", style: .Default, handler: { action in

self.dismissViewControllerAnimated(true, completion: nil)
}))
self.presentViewController(alertController, animated: true, completion: nil)
}

})

} else {

SVProgressHUD.dismiss()
showAlert(title: "Error!", msg: "Email is required in order to reset your password. Please, enter your email. ", actionButton: "OK", viewController: self)
}
}

我用断点对其进行了测试以查看流程,它到达 FIRAuth.auth()?.sendPasswordResetWithEmail(email!, completion: { (error) in 其中电子邮件具有值并且它应该根据它的 if/else 语句执行一些检查,但它没有。

我不知道为什么。该代码正在运行(发送密码恢复电子邮件),但该应用程序因该错误而崩溃。线索?

最佳答案

我想出了问题和解决方案。出于某种原因,问题在线程中。这解决了它:

            FIRAuth.auth()?.sendPasswordResetWithEmail(email!, completion: { (error) in


NSOperationQueue.mainQueue().addOperationWithBlock {

if error != nil {

// Error - Unidentified Email
SVProgressHUD.dismiss()
showAlert(title: "Unidentified Email Address", msg: "Please, re-enter the email you have registered with.", actionButton: "OK", viewController: self)

} else {

// Success - Sends recovery email

SVProgressHUD.dismiss()

let alertController = UIAlertController(title: "Email Sent", message: "An email has been sent. Please, check your email now.", preferredStyle: .Alert)
alertController.addAction(UIAlertAction(title: "OK", style: .Default, handler: { action in

self.dismissViewControllerAnimated(true, completion: nil)
}))
self.presentViewController(alertController, animated: true, completion: nil)
}

}})

关于swift - Firebase 和 Swift 的重置密码问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37628736/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com