2016-06-04 3 views
2

Firebase가 백엔드를 업데이트 한 후 비밀번호 재설정에 문제가 있습니다. 어떤 이유로 앱이 충돌합니다 (재설정 된 비밀번호로 이메일을 발송하더라도). 내가 흐름을 볼 중단 점을 테스트했습니다Firebase 및 Swift로 비밀번호 재설정 문제

@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에 도달 :

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에서 나는 다음과 같습니다 여기에 내가 얻을 콘솔 오류입니다 값 및 그것을 기반으로 일부 검사를 수행해야합니다/else 문을하지만 doesnt.

나는 이유를 모른다. 코드가 작동 중이며 (비밀번호 복구 이메일을 보냈지 만) 해당 오류로 앱이 다운됩니다. 단서?

+0

Objective-C에서도이 오류가 발생합니다. 리셋 암호 API의 완성 처리기가 다른 API와 달리 주 스레드로 돌아 오지 않는 것으로 보입니다. – cclogg

답변

4

문제점과 해결책을 찾아 냈습니다. 어떤 이유로 스레드의 문제가 있습니다. 이 문제가 해결되었습니다 :

  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) 
      } 

      }})