![](/img/trans.png)
[英]iOS Error Code=-1003 “A server with the specified hostname could not be found.”
[英]WKwebView give error intermittently with WebPageProxy error code 1003 in iOS app
我有 iOS 應用程序,其中有 WKWebview。 用於從遠程 URL 加載 HTML。 我在日志中收到錯誤
[Process] 0x1550bfe18 - [pageProxyID=42, webPageID=43, PID=1902] WebPageProxy::didFailProvisionalLoadForFrame: frameID = 3, domain = NSURLErrorDomain, code = -1003
在didFailProvisionalNavigation
方法之后調用 WKWebview。
這是間歇性發生的。 意味着在一段時間內成功使用 WKWebbView 中的網頁,並在一段時間內出現上述錯誤。
同樣的事情在 Android 設備上工作,沒有任何問題。
處理包含不受信任證書的鏈接
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));
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.