The resource could not be loaded because the App Transport Security policy requires the use of a secure connection
I have solved it with adding some key in info.plist.
The steps I followed are:
Opened my Project target's
info.plist
fileAdded a Key called
NSAppTransportSecurity
as aDictionary
.Added a Subkey called
NSAllowsArbitraryLoads
asBoolean
and set its value toYES
as like following image.
Clean the Project and Now Everything is Running fine as like before.
Ref Link: https://stackoverflow.com/a/32609970
EDIT:
OR In source code of info.plist
file we can add that:
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
<key>NSExceptionDomains</key>
<dict>
<key>yourdomain.com</key>
<dict>
<key>NSIncludesSubdomains</key>
<true/>
<key>NSThirdPartyExceptionRequiresForwardSecrecy</key>
<false/>
</dict>
</dict>
</dict>
The resource could not be loaded because the App Transport Security policy requires the use of a secure connection.?
Actually I was trying to update in the wrong info.plist file. My bad :( This is the code I added and it worked fine for me now
<key>NSAppTransportSecurity</key>
<dict>
<key>NSExceptionDomains</key>
<dict>
<key>test.test.com</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
<key>NSIncludesSubdomains</key>
<true/>
<key>NSExceptionAllowsInsecureHTTPLoads</key>
<true/>
<key>NSExceptionRequiresForwardSecrecy</key>
<true/>
<key>NSExceptionMinimumTLSVersion</key>
<string>TLSv1.2</string>
<key>NSThirdPartyExceptionAllowsInsecureHTTPLoads</key>
<true/>
<key>NSThirdPartyExceptionRequiresForwardSecrecy</key>
<false/>
<key>NSThirdPartyExceptionMinimumTLSVersion</key>
<string>TLSv1.2</string>
<key>NSRequiresCertificateTransparency</key>
<false/>
</dict>
</dict>
</dict>
Not allowed to make request to local host - swift
If you edit info.plist
from as source code, to allow all domains, change the values like:
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
Then it should look like below as Property List:
or
For a better way, you can disable it by default and add exceptions for specific domains like below.
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<false/>
<key>NSExceptionDomains</key>
<dict>
<key>yourdomain.com</key>
<dict>
<key>NSExceptionAllowsInsecureHTTPLoads</key>
<true/>
<key>NSIncludesSubdomains</key>
<true/>
</dict>
</dict>
</dict>
App Transport Security policy error after setting Arbitrary Loads to YES
This structure is wrong:
<key>NSExceptionDomains</key>
<dict>
<key>The domain</key>
<dict>
<key>**my domain here**</key>
<dict/>
</dict>
<key>NSIncludesSubdomains</key>
<true/>
<key>NSExceptionAllowsInsecureHTTPLoads</key>
<true/>
</dict>
It should be:
<key>NSExceptionDomains</key>
<dict>
<key>The domain</key>
<dict>
<key>NSIncludesSubdomains</key>
<true/>
<key>NSExceptionAllowsInsecureHTTPLoads</key>
<true/>
</dict>
</dict>
Simulator show error about App Transport Security policy requires the use of a secure connection
you need this in your info.plist to do a http request
Related Topics
React-Native, How to Get File-Asset Image Absolute Path
Ios Simple Tcp Connection Example
How to Embed a Custom Font in an Iphone Application
Getting the Difference Between Two Dates (Months/Days/Hours/Minutes/Seconds) in Swift
Iphone Get Ssid Without Private Library
Uialertcontroller Custom Font, Size, Color
Objective-C Arc: Strong VS Retain and Weak VS Assign
How to Make a Simple Collection View With Swift
Set Padding For Uitextfield With Uitextborderstylenone
How to Get the Root Directory of My iOS App
React Native App Crashes on Launch Screen on Device
Presenting Modal in iOS 13 Fullscreen
Opening the Settings App from Another App
Exc_Bad_Access Signal Received
Status Bar and Navigation Bar Issue in Ios7
How to Check If a String Contains Another String in Objective-C