简体   繁体   中英

HTTP load request is not working in iOS12

I having an application which open the direction between two location in a webview using " http://maps.google.com " URL. but it is not working in iOS12. And also enabled the exceptional domain in App transport security plist value. Even though it is not working.

Please update your iOS 12 as the latest version asap.

iOS 12 beta version has an issue of CORS with wkwebview .

Refer to this link.

And it has been fixed now.

For me, the issue was caused by server trust check from the WKWebView.

To fix this I had to handle the challenge authentication callback and return a server trust credential.

Swift 4

func webView(_ webView: WKWebView, 
    didReceive challenge: URLAuthenticationChallenge, 
    completionHandler: @escaping (URLSession.AuthChallengeDisposition, URLCredential?) -> Void) 
{
    if(challenge.protectionSpace.authenticationMethod == NSURLAuthenticationMethodServerTrust)
    {
        let cred = URLCredential(trust: challenge.protectionSpace.serverTrust!)
        completionHandler(.useCredential, cred)
    }
    else
    {
        completionHandler(.performDefaultHandling, nil)
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM