Reputation: 3
I'm trying to get my button to allow the user to log out of their google account and Firebase account when clicking this button. the sign out code given on firebase's website currently does not work.
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
if indexPath.section == 0 && indexPath.row == 0 {
print("pressed")
let firebaseAuth = Auth.auth()
do {
try firebaseAuth.signOut()
} catch let signOutError as NSError {
print ("Error signing out: %@", signOutError)
}
}
Upvotes: 0
Views: 386
Reputation: 100503
signOut
won't redirect your app to login screen you have to do it manually
override func tableView(_ tableView: UITableView, didSelectRowAt i ndexPath: IndexPath) {
if indexPath.section == 0 && indexPath.row == 0 {
print("pressed")
let firebaseAuth = Auth.auth()
do {
try firebaseAuth.signOut()
let vc = self.storyboard?.instantiateViewController(withIdentifier: "loginView")
self.navigationController?.setViewControllers([vc!], animated: false)
} catch let signOutError as NSError {
print ("Error signing out: %@", signOutError)
}
}
Upvotes: 1