0

I am trying to load a webpage that is under a local network after the device connects to a specific WiFi.

I am getting this error:

WebPageProxy::didFailProvisionalLoadForFrame: frameID = 3, domain = NSURLErrorDomain, code = -1202

I can load any other webpage I try with no issues.

I can pull up the webpage on Safari in the xcode simulator and I am able to see it, but I do get the "This Connection is Not Private" page before and have to click the "visit this website" button. Not sure if this is the problem.

davidatherton
  • 11
  • 1
  • 3
  • The connection not being private issue is almost certainly the root of it. Does it work if you change the transport security rules? https://stackoverflow.com/a/40299837/560942 – jnpdx May 11 '21 at 16:03
  • @jnpdx I've tried to allow arbitrary loads and that didn't change anything. – davidatherton May 11 '21 at 16:09

1 Answers1

6

In addition to allow arbitrary load in Info you may need to implement this function in your WKNavigationDelegate

func webView(_ webView: WKWebView, didReceive challenge: URLAuthenticationChallenge, completionHandler: @escaping (URLSession.AuthChallengeDisposition, URLCredential?) -> Void) {
    guard let serverTrust = challenge.protectionSpace.serverTrust  else {
        completionHandler(.useCredential, nil)
        return
    }
    let credential = URLCredential(trust: serverTrust)
    completionHandler(.useCredential, credential)
    
}