Google使用Firebase退出按钮

时间:2018-02-18 21:16:55

标签: ios firebase firebase-authentication

我试图让我的按钮允许用户在点击此按钮时退出他们的Google帐户和Firebase帐户。 firebase网站上提供的注销码目前无效。

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

1 个答案:

答案 0 :(得分:1)

signOut无法将您的应用重定向到登录屏幕,您必须手动执行此操作

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