Reputation: 5194
I am trying to load HTTP links within UIWebView. The links are from my website so they are reliable. I have searched the internet and found the solution here: How can I add NSAppTransportSecurity to my info.plist file?
After following that solution my info.plist looks like this.:
Even after making the changes I cannot load HTTP links within UIWebView. I get the following error:
App Transport Security has blocked a cleartext HTTP (http://) resource load since it is insecure
Is there something I am doing wrong?
UPDATE:
After making the changes suggested by Ramshad in comments it still does not work. See image below:
Upvotes: 11
Views: 11442
Reputation: 4994
Check this article: link.
App Transport Security (ATS) normally doesn’t allow our apps to connect to HTTP servers, but there’s a special exception you can add to allow UIWebView and WKWebView to load insecure content.
TL;DR
Just add to your .plist
file:
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoadsInWebContent</key>
<true/>
</dict>
NSAllowsArbitraryLoadsInWebContent
is available from iOS 9.0 so should be fine for you.
Upvotes: 2
Reputation: 21
I think you have misspelled the link or a domain.
I had the same problem and after checking again the domain which was 123.company.othercompany.com
, so I changed company.com
to othercompany.com
and it started to load external website.
Upvotes: 0
Reputation: 142
Have you tried this?
<key>NSAppTransportSecurity</key>
<dict>
<key>NSExceptionDomains</key>
<dict>
<key>www.mydomain.com</key>
<dict>
<key>NSIncludesSubdomains</key>
<true/>
<key>NSExceptionMinimumTLSVersion</key>
<string>TLSv1.0</string>
<key>NSExceptionRequiresForwardSecrecy</key>
<false/>
<key>NSExceptionAllowsInsecureHTTPLoads</key>
<true/>
</dict>
</dict>
</dict>
Upvotes: 0
Reputation: 1971
It should be done like this, you need to add in your Plist the following records Apple Documentation
NSAppTransportSecurity <- Type Dictionary
NSAllowsArbitraryLoads <- Type Boolean Value YES
Upvotes: 17
Reputation: 483
Can you try to add the all thing, without "http://":
<key>NSAppTransportSecurity</key>
<dict>
<key>NSExceptionDomains</key>
<dict>
<key>mydomain.com</key>
<dict>
<key>NSExceptionAllowsInsecureHTTPLoads</key>
<true/>
<key>NSIncludesSubdomains</key>
<true/>
<key>NSExceptionRequiresForwardSecrecy</key>
<false/>
</dict>
</dict>
</dict>
Upvotes: 3