Auth0 Home Blog Docs

iOS 13 - iOS SDK fails instantly - presentation context error

let domain = "...."
        Auth0
            .webAuth()
            .audience("https://" + domain + "/userinfo")
            .connection("google-oauth2")
            .parameters(["prompt":"login"])
            .scope("openid profile email offline_access")
            .start { [weak self] result in
                DispatchQueue.main.async {
                    switch result {
                    case .success(let credentials):
                        self?.handleLoginCredentials(credentials: credentials)
                    case .failure(let error):
                        if let err = error as? URLError, err.code  == URLError.Code.notConnectedToInternet {
                            self?.loginDelegate?.onLoginFail(.networkError)
                        } else {
                            self?.loginDelegate?.onLoginFail(.notAllowed)
                        }
                    }
                }
        }

Error:
Error Domain=com.apple.AuthenticationServices.WebAuthenticationSession Code=2 “Cannot start ASWebAuthenticationSession without providing presentation context. Set presentationContextProvider before calling -start.” UserInfo={NSDebugDescription=Cannot start ASWebAuthenticationSession without providing presentation context. Set presentationContextProvider before calling -start.}

Hey there @Engineer!

Got one question. Are you trying to compile it on real device? Was wondering if it’s not affected by new changes to Apple stack because of iOS 13 and potentially the changes we need to make to our SDK. Have you tried raising a GitHub issue in our appropriate repo?

Apple did change their stack, presentation context is required now with iOS 13. Works ok on previous iOS versions.

Got it! Can you raise such issue in our GitHub repo and share it here? This way it will be easier for repo maintainers to communicate updates with you

1 Like