Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WKWebView iOS 10.3 crash for didReceiveAuthenticationChallenge?

Tags:

func webView(webView: WKWebView, didReceiveAuthenticationChallenge challenge: NSURLAuthenticationChallenge, completionHandler: (NSURLSessionAuthChallengeDisposition, NSURLCredential?) -> Void) {
    var user: String?
    var password: String?
    switch providerID {
    case "197": // ABC Stagging
        user = "ABC"
        password = "abc"
    default:
        break
    }
    if let user = user, password = password {
        let credential = NSURLCredential(user: user, password: password, persistence: NSURLCredentialPersistence.ForSession)
        challenge.sender?.useCredential(credential, forAuthenticationChallenge: challenge)
        completionHandler(NSURLSessionAuthChallengeDisposition.UseCredential, credential)
    }
}

According to crashlytics crash is happening on line with info The challenge was not sent by the receiver.

    challenge.sender?.useCredential(credential, forAuthenticationChallenge: challenge)

Any help is appreciated. This happens only on iOS 10.3. I guess some users have beta and are experiencing this.

like image 418
Ankit Srivastava Avatar asked Feb 21 '17 18:02

Ankit Srivastava


1 Answers

Same problem for me, I fixed it by commented this line

//    challenge.sender?.useCredential(credential, forAuthenticationChallenge: challenge)
like image 164
StrawHara Avatar answered Sep 21 '22 10:09

StrawHara