Roh*_*ale 1 webproxy ios wkwebview
我有 iOS 应用程序,其中有 WKWebview。用于从远程 URL 加载 HTML。我在日志中收到错误
[Process] 0x1550bfe18 - [pageProxyID=42, webPageID=43, PID=1902] WebPageProxy::didFailProvisionalLoadForFrame: frameID = 3, domain = NSURLErrorDomain, code = -1003
Run Code Online (Sandbox Code Playgroud)
按照该didFailProvisionalNavigation方法调用 WKWebview。
这是间歇性发生的。意味着在 WKWebbView 中成功使用网页一段时间,并在一段时间内出现上述错误。
同样的事情在 Android 设备上运行没有任何问题。
小智 10
处理包含不受信任证书的链接
func webView(_ webView: WKWebView, didReceive challenge: URLAuthenticationChallenge, completionHandler: @escaping (URLSession.AuthChallengeDisposition, URLCredential?) -> Void) {
guard let serverTrust = challenge.protectionSpace.serverTrust else {
completionHandler(.cancelAuthenticationChallenge, nil)
return
}
let exceptions = SecTrustCopyExceptions(serverTrust)
SecTrustSetExceptions(serverTrust, exceptions)
completionHandler(.useCredential, URLCredential(trust: serverTrust));
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
12827 次 |
| 最近记录: |