5
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)
    }
}

根据 crashlytics,崩溃发生在与 info 一致的情况下,接收方未发送挑战。

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

任何帮助表示赞赏。这仅在 iOS 10.3 上发生。我猜有些用户有测试版并且正在经历这个。

4

1 回答 1

4

对我来说同样的问题,我通过评论这一行来解决它

//    challenge.sender?.useCredential(credential, forAuthenticationChallenge: challenge)
于 2017-03-01T09:41:35.033 回答