簡體   English   中英

WKwebView 在 iOS 應用程序中間歇性給出錯誤,WebPageProxy 錯誤代碼為 1003

[英]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 設備上工作,沒有任何問題。

  1. 為什么它不是一直失敗?
  2. 這是 iOS 應用程序的問題嗎?
  3. 這是服務器問題嗎?
  4. 服務器出現此錯誤的原因是什么?
  5. 我需要在服務器上更新哪個配置?

處理包含不受信任證書的鏈接

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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM