I have implemented google SignIn in my iOS app and can login to google account for the first time. But when I logout and try to log back in, I get Account Permission screen as shown below with last user instead of SignIn screen.
Below is the code I've used.
var signIn = GIDSignIn.sharedInstance()
signIn.delegate = self
signIn.uiDelegate = self
Below is code to sign out & disconnect
GIDSignIn.sharedInstance().signOut()
GIDSignIn.sharedInstance().disconnect()
After disconnecting, I again try to SignIn using below code
GIDSignIn.sharedInstance().signIn()
How can I display login screen after Signing out & Disconnecting?
I was stuck on this for a while and I came up with a pretty hacky solution.
It seems the GIDSignIn account listing is using a Safari Web View, so its record of the accounts is using cookies/local storage and is independent of the iOS Keychain (and OAuth tokens).
When a user hits logout on my app I'm opening a SFSafariViewController like so:
import SafariServices
class MyViewController: SFSafariViewControllerDelegate {
...
inside your button action (or where you want to log the user out):
let logoutUrl = URL(string: "https://www.google.com/accounts/Logout")!
let logoutViewController = SFSafariViewController.init(url: logoutUrl)
logoutViewController.delegate = self
self.present(logoutViewController, animated: true, completion: nil)
where you implement the didCompleteInitialLoad
delegate method and dismiss your view controller like the following:
func safariViewController(_ controller: SFSafariViewController, didCompleteInitialLoad didLoadSuccessfully: Bool) {
controller.dismiss(animated: false) {
//Switch view controllers
}
}
This seems to be the only way I can figure out.
来源:https://stackoverflow.com/questions/39129888/google-signin-unable-to-disconnect-ios-app