WKWebView iOS 10.3 crash for didReceiveAuthenticationChallenge?

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 occurs online with information The task was not sent by the recipient.

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

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

+4
source share
1 answer

Same issue for me, I fixed it by commenting on this line

//    challenge.sender?.useCredential(credential, forAuthenticationChallenge: challenge)
+1
source

Source: https://habr.com/ru/post/1670454/


All Articles