simon
simon

Reputation: 117

Swift UIWebView not loading http sites

I created a web view controller and it loads https sites(ex: , ) but not http, non ssl secured sites(ex: http://bswd.us, http://www.barretthillins.com). When i do put a hhtp site in there, it does load but just a blank, white web view. How would i need to fix this?

Upvotes: 8

Views: 12999

Answers (2)

Eden
Eden

Reputation: 1820

You can also allow access to http content just through webviews, by adding this instead:

<key>NSAppTransportSecurity</key>
<dict>
    <key>NSAllowsArbitraryLoadsInWebContent</key>
    <true/>
</dict>

Upvotes: 4

Julian E.
Julian E.

Reputation: 4755

This is due to the App Transport Security, a new protocol introduced by Apple at WWDC 2015. It doesn't allow any connections that are not HTTPS. You can disable it, however it's not recommended as it secures your app.

To disable it you have to edit the App's .plist. Simply right-click the .plist file and select Open As -> Source File and add the following code:

<key>NSAppTransportSecurity</key>
<dict>
    <key>NSAllowsArbitraryLoads</key><true/>
</dict>

This will allow HTTP requests.

Hope that helps, Julian.

Upvotes: 25

Related Questions