WKwebView give error intermittently with WebPageProxy error code 1003 in iOS app
Asked Answered
M

1

2

I have iOS app in which I have WKWebview. Used for loading HTML from remote URL. I get the error in log

[Process] 0x1550bfe18 - [pageProxyID=42, webPageID=43, PID=1902] WebPageProxy::didFailProvisionalLoadForFrame: frameID = 3, domain = NSURLErrorDomain, code = -1003

Following that didFailProvisionalNavigation method get call for WKWebview.

This is happening intermittently. Means successfully work with webpage in WKWebbView some time and above error for some time.

Same thing is working on Android device without any issue.

  1. Why it is not failing all the time?
  2. is this the issue with iOS app?
  3. is this the server issue?
  4. What cause the server gives this error?
  5. which configuration I need to update on server?
Mcclintock answered 31/3, 2021 at 12:55 Comment(0)
O
11

Handling links containing untrusted certificates

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));
}
Origan answered 20/5, 2021 at 6:43 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.