JonahGabriel
JonahGabriel

Reputation: 3104

ATS setting NSAllowsArbitraryLoadsInWebContent not working

I am trying to get the ATS setting NSAllowsArbitraryLoadsInWebContent working in my iOS app and for some reason, the setting seems be be ignored. I put together a quick test app to make sure none of my other Info.plist settings were breaking things, but insecure links are still getting rejected in both UIWebViews and WKWebViews. Here are the ATS settings in my Info.plist file:

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

And here is my the code in my controller with the UIWebView:

  override func viewDidLoad() {
        super.viewDidLoad()
        webView.delegate = self
        let url = URL(string: "https://www.salliemae.com/smartoption/")
        let request = URLRequest(url: url!)
        self.webView.loadRequest(request)
    }

Any help would be appreciated.

Upvotes: 3

Views: 6248

Answers (3)

Krishna Vedula
Krishna Vedula

Reputation: 1791

You could add the following in the Info.plist file, and rerun. This would allow any arbitrary content to be loaded in the UiWebView.

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

Upvotes: 0

JonahGabriel
JonahGabriel

Reputation: 3104

So it looks like the issue was due to a bug in the version of Xcode I was using that wasn't respecting the NSAllowsArbitraryLoadsInWebContent flag. Updating to Xcode 8.2 beta (8c30a) fixed the issue.

Upvotes: 1

ZhiyiLiu
ZhiyiLiu

Reputation: 9

You'll need to be more specific. And I saw a similar question in apple developer forum,wish this could be helpful:NSAllowsArbitraryLoadsInWebContent in UIWebView

Upvotes: 0

Related Questions