Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error loading web in UIWebView

I'm using an UIWebView and I can't load facebook. I have to say that I'm using xcode 7 beta 2 and iOS 9.0 beta 4.

This is the error:

Error Domain=NSURLErrorDomain Code=-1022 "The resource could not be loaded because the App Transport Security policy requires the use of a secure connection."
like image 707
Alex Delgado Avatar asked Jul 23 '15 16:07

Alex Delgado


1 Answers

So, I will answer my own question. As CSmith answered, apple wants us to use App Transport Security (ATS). But yet, as there are many people not ready, I'll show the way to avoid it. In your info.plist add the next thing:

<key>NSAppTransportSecurity</key>
<dict>
  <!--Include to allow all connections (DANGER)-->
  <key>NSAllowsArbitraryLoads</key>
  <true/>
</dict>

related: iOS 9 ... Are WebView(s) exempt from the App Transport Security Exceptions (ATS) rules that block insecure HTTP hosts?

like image 173
Alex Delgado Avatar answered Oct 08 '22 18:10

Alex Delgado