11

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.:

enter image description here

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:

enter image description here

Community
  • 1
  • 1
Skywalker
  • 4,984
  • 16
  • 57
  • 122

6 Answers6

17

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

enter image description here

Grigori Jlavyan
  • 1,871
  • 3
  • 19
  • 39
3

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>
Paul Slm
  • 403
  • 3
  • 11
2

enter image description here

Try this, this should fix your issue

Community
  • 1
  • 1
Prabhu.Somasundaram
  • 1,380
  • 10
  • 13
  • Thank you for the reply. Please see my updated question. I have tried this but it does not work for me. – Skywalker Sep 21 '15 at 10:18
2

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.

Kamil Harasimowicz
  • 4,684
  • 5
  • 32
  • 58
0

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>
lidia
  • 144
  • 3
  • 7
0

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.