Swift2.0 HTTP request not working [duplicate] - ios

This question already has answers here:
Transport security has blocked a cleartext HTTP
(29 answers)
Closed 7 years ago.
Hello Stackoverflow,
I keep getting this error after I moved my swift app onto Swift2.0:
App Transport Security has blocked a cleartext HTTP (http://) resource load since it is insecure. Temporary exceptions can be configured via your app's Info.plist file.
The resource could not be loaded because the App Transport Security policy requires the use of a secure connection.
And I took a look at the following link https://forums.developer.apple.com/thread/5835
and added the following code to my info.plist
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
<key>NSExceptionDomains</key>
<dict/>
</dict>
And it still doesn't work, anyone have an alternative solution?

Its not a Swift 2.0 issue its actually an iOS 9.0 issue where iOS 9.0 forces web traffic to go over https setting the below flag allows http traffic.
You have to set the NSAllowsArbitraryLoads key to YES under NSAppTransportSecurity dictionary in your .plist file. Hope this helps!

Related

Transport security has blocked a cleartext HTTP (XCode 8) [duplicate]

This question already has answers here:
Transport security has blocked a cleartext HTTP
(29 answers)
Closed 5 years ago.
I'm trying to write a Swift app that pulls the RSS feed from a blog and displays it onto the screen. There's an error: App Transport Security has blocked a cleartext HTTP (http://) resource load since it is insecure. Temporary exceptions can be configured via your app's Info.plist file.
How do I configure the one blog's website Info.plist to be an exception? There is no NSAllowsArbitraryLoads option in the drop-down menu.
Add to your Info.plist file:
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>

iOS9 App Transport Security

I am attempting to send a http:// request however, ATS keeps blocking my request. I have turned on Allow Arbitrary Loads in the Info.plist and it still gives me the same error:
App Transport Security has blocked a cleartext HTTP (http://) resource load since it is insecure. Temporary exceptions can be configured via your app's Info.plist file.
You can add exceptions for specific domains in your Info.plist
You can bypass this by adding this key to your info.plist of the project
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
Your dictionary App Transport Security Settings should be named NSAppTransportSecurity. And there should be only one thing in there which is NSAllowsArbitraryLoads boolean. Something like this.

App Transport Security has blocked a cleartext HTTP Xcode7.1

guys. I set my info.plist as the picture
however,there is still the problem there:" App Transport Security has blocked a cleartext HTTP (http://) resource load since it is insecure. Temporary exceptions can be configured via your app's Info.plist file.
" . I update my Xcode yestoday. the vision is 7.1 . and simulator`s vision is 9.1
Is there similer question here?
Open Info.plist and change that text with NSAllowsArbitraryLoads and your issue will be resolved.
Or open Info.plist file in Source Code mode and replace the following lines:
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>

app transport security has blocked a cleartext http resource load since it is insecure [duplicate]

This question already has answers here:
How do I load an HTTP URL with App Transport Security enabled in iOS 9? [duplicate]
(8 answers)
Closed 7 years ago.
Though I followed App Transport Security Technote and Configuring App Transport Security Exceptions in iOS 9 and OSX 10.11 still I'm getting this error in iOS 9 ERROR:App transport security has blocked a cleartext http resource load since it is insecure
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
just paste this code in plist

iOS 9 ... Are WebView(s) exempt from the App Transport Security Exceptions (ATS) rules that block insecure HTTP hosts?

In iOS 9, Apple is blocking insecure HTTP connections for apps, unless specific hosts are whitelisted.
http://ste.vn/2015/06/10/configuring-app-transport-security-ios-9-osx-10-11/
Are WebView(s) exempt from these rules for obvious reasons, or are we still expected to whitelist hosts that a browser opens... including all links from a given page?
I wasn't sure if this was our responsibility or if that was exempt.
SFSafariViewController can show HTTP without the NSAppTransportSecurity key.
UIWebView and WKWebView require the NSAppTransportSecurity key mentioned above to display HTTP pages.
I have inserted the following in my apps .plist per the Apple Guidance:
<key>NSAppTransportSecurity</key>
<dict>
<!--Include to allow all connections - with and without SSL (DANGEROUS)-->
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
and when I try to load my webView (from an HTTPS server no less), I get the following error and it doesn't load.
NSURLSession/NSURLConnection HTTP load failed (kCFStreamErrorDomainSSL, -9813)
So I it looks like not only are they not exempt, they don't work even if you make the correct addition to the .plist.
This question was originally about iOS 9; however, according to Apple's documentation:
Starting in iOS 10.0 and later, the following subkeys are supported:
NSAllowsArbitraryLoadsInWebContent
...
Use NSAllowsArbitraryLoadsInWebContent so that you do not need to white list each page a WebView may load.
Keep NSAllowsArbitraryLoads to maintain backward compatibility with iOS 9 and enable the new setting in your Xcode 8 project Info.plist here:
If your app (a third-party web browser, for instance) needs to load arbitrary content, Apple provides a way to disable ATS altogether, but I suspect it’s wise for you to use this capability sparingly:
<key>NSAppTransportSecurity</key>
<dict>
<!--Include to allow all connections (DANGER)-->
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>

Resources