4

I made app which login in SFSafariViewController. It works well when login. but after I logout if I try to login it again, I'm already logged in. This is because my automatic login information is stored in SFSafariViewController. I tried to delete cache and cookies but it doesn't work. :(

this is my login code.

func requestCode() {
        let scope = "user"
        let urlString = "https://github.com/login/oauth/authorize?client_id=\(clientId)&scope=\(scope)"
        guard let url = URL(string: urlString) else {
            return
        }
        
    URLCache.shared.removeAllCachedResponses()

    if let cookies = HTTPCookieStorage.shared.cookies {
        for cookie in cookies {
            HTTPCookieStorage.shared.deleteCookie(cookie)
        }
    }
    
    let safariViewController = SFSafariViewController(url: url)
    safariViewController.delegate = self
    safariViewController.modalPresentationStyle = .automatic
    
    if let topViewController = UIApplication.shared.connectedScenes.compactMap({ $0 as? UIWindowScene }).flatMap({ $0.windows }).first(where: { $0.isKeyWindow }) {
        topViewController.rootViewController?.present(safariViewController, animated: true, completion: nil)
    }
}
PArk
  • 51
  • 1

1 Answers1

0

prefersEphemeralWebBrowserSession = true it makes your browser to private mode!!! so you don't need to logout.

PArk
  • 51
  • 1