Google SignIn: Unable to disconnect iOS app

大憨熊 提交于 2019-12-05 09:14:52

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!