火力地堡登出斯威夫特
问题描述:
不工作
我使用最新的火力地堡API(3.2.1),我使用此代码来检查,如果用户在签署:火力地堡登出斯威夫特
override func viewDidAppear(animated: Bool) {
super.viewDidAppear(animated)
if(self.navigationController != nil){
self.navigationController!.setNavigationBarHidden(true, animated: true)
}
if(FIRAuth.auth() != nil){
self.performSegueWithIdentifier("loginSuccessSegue", sender: self)
}
}
换句话说,如果身份验证对象存在我正在切换到其他控制器。在该控制器我已经登出按钮,这是做登出这样的:
do{
try FIRAuth.auth()?.signOut()
self.performSegueWithIdentifier("logoutSegue", sender: self)
}catch{
print("Error while signing out!")
}
我不会对此操作出现错误,但是当我切换到登录控制器,此身份验证物体是否存在,我得到转回再次向控制器提供数据。我也尝试在auth中检查当前用户对象,并且它存在并且有效。
任何人都知道我该如何正确退出?
答
尝试使用:
try! FIRAuth.auth()!.signOut()
这是我在一个IBAction为代码,它的工作只是罚款:
try! FIRAuth.auth()!.signOut()
if let storyboard = self.storyboard {
let vc = storyboard.instantiateViewControllerWithIdentifier("firstNavigationController") as! UINavigationController
self.presentViewController(vc, animated: false, completion: nil)
}
我实现了这个在我自己的应用程序,从一点点帮助威力在Firebase。你可以添加一个监听器,正如我在[this]中所描述的(http://stackoverflow.com/questions/39301815/firebase-ios-swift-firauth-auth-signout-not-signing-out-current-user#answer- 40412452)答案。 –