App Transport Security Blocked Fix
The Error
Got the following error in your app when trying to run it? Connections to websites not working in your app? Well there is a simple fix below!
Why Does This Occur
This happens, as from iOS 9 onwards, Apple enforced HTTPS connections that use TLS v1.2 or greater security. This is to protect users, and yourself to man in the middle attacks, and other vulnerabilities that come along with an unsecured connection.
How To Fix
Luckily Apple allows us to either disable this in our App completely, or whitelist URLS that we do not want this security to apply to.
The Easy Fix (Disable App Transport Security)
- Select your project
- Select the target
- Choose the info tab
- Right click on Bundle OS Type Code, select Add Row and choose “App Transport Security Settings” from the dropdown
- Right click on the newly created App Transport Security Settings row, select Add Row and choose “Allow Arbitrary Loads“
- Set this value to YES
This will allow all communication via http, and https, regardless of the url.
The Hard Fix (Whitelist your URL’s)
- Right click on your projects Info.plist file
- Select Open As –> Source Code
- Add the following keys and URLS to your source file, add
<key>NSAppTransportSecurity</key> <dict> <key>seemuapps.com</key> <dict> <!--Include to allow subdomains--> <key>NSIncludesSubdomains</key> <true/> <!--Include to allow HTTP requests--> <key>NSTemporaryExceptionAllowsInsecureHTTPLoads</key> <true/> <!--Include to specify minimum TLS version--> <key>NSTemporaryExceptionMinimumTLSVersion</key> <string>TLSv1.1</string> </dict> </dict>
This will allow all communication to seemuapps.com via HTTP, if you have multiple domains you simply add them to the list.