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

4
  • forums.developer.apple.com/thread/3544 Commented Sep 21, 2015 at 8:49
  • @Ramshad please see update. Commented Sep 21, 2015 at 9:22
  • I have the same issue, any update that works? Commented Apr 25, 2016 at 21:43
  • @ewindsor have a look at my answer on this question but note that this will allow all connections. But this is the only way I could get it to work. stackoverflow.com/questions/33011558/… Commented Apr 26, 2016 at 7:22

6 Answers 6

17
+250

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

Sign up to request clarification or add additional context in comments.

Comments

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>

Comments

2

enter image description here

Try this, this should fix your issue

1 Comment

Thank you for the reply. Please see my updated question. I have tried this but it does not work for me.
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.

Comments

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>

Comments

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.