How to Sign Out of Google After Being Authenticated

后端 未结 6 984
伪装坚强ぢ
伪装坚强ぢ 2021-02-06 23:54

So my app has the option to sign in with Google. Upon clicking the button that Google provides, a web view opens and has the user input their credentials. After allowing the app

6条回答
  •  情深已故
    2021-02-06 23:55

      public func logOut(on:UIViewController){
    
        let firebaseAuth = Auth.auth()
        do {
            try  firebaseAuth.signOut()
                GIDSignIn.sharedInstance().signOut()
                GIDSignIn.sharedInstance().disconnect()
    
            if let url = NSURL(string:  "https://www.google.com/accounts/Logout?continue=https://appengine.google.com/_ah/logout?continue=https://google.com"){
                UIApplication.shared.open(url as URL, options: [:]) { (true) in
                    let appDel:AppDelegate = UIApplication.shared.delegate as! AppDelegate
                    appDel.window?.rootViewController = LoginViewController()
                }
            }
        } catch let signOutError as NSError {
            Help.shared.Snack(messageString: "Error signing out: \(signOutError)" 
    )
            print ("Error signing out: %@", signOutError)
        }
    }
    

提交回复
热议问题