【发布时间】:2018-10-22 12:00:14
【问题描述】:
我有一个应用程序,它使用“http://maps.google.com”URL 打开 web 视图中两个位置之间的方向。但它不适用于iOS12。并且还启用了 App 传输安全 plist 值中的异常域。即使它不起作用。
【问题讨论】:
-
给我们看一些代码。发生什么了?您收到错误消息吗?
-
更新设备,现已发布ios12
我有一个应用程序,它使用“http://maps.google.com”URL 打开 web 视图中两个位置之间的方向。但它不适用于iOS12。并且还启用了 App 传输安全 plist 值中的异常域。即使它不起作用。
【问题讨论】:
【讨论】:
对我来说,这个问题是由 WKWebView 的服务器信任检查引起的。
要解决此问题,我必须处理质询身份验证回调并返回服务器信任凭据。
斯威夫特 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)
}
}
【讨论】: