[webView webView:didReceiveAuthenticationChallenge:completionHandler:] was not

1,210 阅读1分钟

项目中使用了WebViewJavascriptBridge这个框架,导致崩溃。

Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Completion handler passed to -[xxx.HWebView webView:didReceiveAuthenticationChallenge:completionHandler:] was not called'

  • 解决方法:

github上解决方案

  • oc版本对应的解决方法
(void)webView:(WKWebView *)webView didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge completionHandler:(void (^)(NSURLSessionAuthChallengeDisposition disposition, NSURLCredential * _Nullable credential))completionHandler
{
completionHandler(NSURLSessionAuthChallengePerformDefaultHandling, nil);
}
  • swift 对应的解决方法:
  func webView(_ webView: WKWebView, didReceive challenge: URLAuthenticationChallenge, completionHandler: @escaping (URLSession.AuthChallengeDisposition, URLCredential?) -> Void) {
        completionHandler(URLSession.AuthChallengeDisposition.performDefaultHandling,nil)
    }