我尝试检查Firebase中是否已存在经过身份验证的用户。我发现user?.reauthenticate
可以解决这个问题,但不幸的是,当我运行它时,它会卡在reauthenticate
方法上。我在控制台中看不到任何错误消息。我在iOS模拟器上运行代码。
有人可以帮我这个吗?难道我做错了什么?感谢
func loginButton(_ loginButton: FBSDKLoginButton!, didCompleteWith result: FBSDKLoginManagerLoginResult!, error: Error!) {
self.loginButton.isHidden = true
self.loadspinnerAIV.startAnimating()
if(error != nil){
//handle errors
self.loginButton.isHidden = false
self.loadspinnerAIV.stopAnimating()
}else if(result.isCancelled){
//handle cancel event
self.loginButton.isHidden = false
self.loadspinnerAIV.stopAnimating()
}else{
let credential = FIRFacebookAuthProvider.credential(withAccessToken: FBSDKAccessToken.current().tokenString)
let user = FIRAuth.auth()?.currentUser
// Prompt the user to re-provide their sign-in credentials
user?.reauthenticate(with: credential) { error in
if let error = error {
print ("User does not exist")
FIRAuth.auth()?.signIn(with: credential) { (user, error) in}
} else {
print ("User does exist")
self.performSegue(withIdentifier: "showHome", sender: self)
}
}
}
}.