App Transport Security破坏了Web视图 [英] App Transport Security breaks Web View
问题描述
我在iOS8下运行良好的应用不再在iOS9下运行.问题是,尽管我的.plist文件中包含以下内容:
My app which works great under iOS8 no longer runs under iOS9. The problem is that despite having the following in my .plist file:
<key>NSAppTransportSecurity</key>
<dict>
<!--Include to allow all connections (DANGER)-->
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
以下代码:
NSURL *targetURL = [NSURL URLWithString:_caseStudyListTitleURL];
NSURLRequest *request = [NSURLRequest requestWithURL:targetURL];
[_myWebView loadRequest:request];
导致错误:
NSURLSession/NSURLConnection HTTP加载失败(kCFStreamErrorDomainSSL,-9813)
results in the error:
NSURLSession/NSURLConnection HTTP load failed (kCFStreamErrorDomainSSL, -9813)
这当然会导致显示一个空的WebView.
This of course leads to an empty webView being displayed.
应用程序中的所有其他NSURLSession代码均正常运行.
All other NSURLSession Code in the app is functioning correctly.
我正在测试iPad上运行XCode 7 Beta 3和iOS 9.
I am running XCode 7 Beta 3 and iOS 9 on my test iPad.
任何对此的想法将不胜感激!
Any ideas on this would be greatly appreciated!
推荐答案
尝试以下解决方案:
<key>NSAppTransportSecurity</key>
<dict>
<key>NSExceptionDomains</key>
<dict>
<key>yourdomain.com</key>
<dict>
<key>NSIncludesSubdomains</key>
<true/>
<key>NSTemporaryExceptionAllowsInsecureHTTPLoads</key>
<true/>
<key>NSTemporaryExceptionMinimumTLSVersion</key>
<string>TLSv1.1</string>
</dict>
</dict>
</dict>
这篇关于App Transport Security破坏了Web视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!