Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Api Call Error in Xcode 7 / iOS 9 (how to setup App Transport Security in plist)

I am using xcode 7 beta version. Now, I am working an API. If, I use the API in Xcode 6.3 it works fine but when same API I used in xcode 7 error message appears Unable to parse.

here is the API i am using

Please help me out. Thanks in Advance

like image 401
Manish Gumbal Avatar asked Jun 17 '15 10:06

Manish Gumbal


People also ask

How do I enable app transport security?

App Transport Security (ATS) is enabled by default when using NSURLSession , NSURLConnection , or CFURL in iOS 9 or OS X El Capitan which enforces the application to use HTTPS with TLS 1.2 for all the network communications with the back end server.

How would you explain APP transport security to a new iOS developer?

App Transport Security (ATS) is an iOS feature that forces mobile apps to connect to back-end servers using HTTPS, instead of HTTP, to encrypt data in transit. ATS enforces a minimum security level for communications between a mobile app and web services that support its functionality.

How do I allow HTTP requests in Xcode?

If you need to hit the HTTP request from Xcode and above you need to specify the URL in info. plist file to allow the request. You can allow all the http request by adding arbitrary load to “YES” in info. plist file.


2 Answers

In iOS9, Apple added new feature called App Transport Security(ATS).

ATS enforces best practices during network calls, including the use of HTTPS.

Apple Pre-release documentation:

ATS prevents accidental disclosure, provides secure default behavior, and is easy to adopt. You should adopt ATS as soon as possible, regardless of whether you’re creating a new app or updating an existing one.

If you’re developing a new app, you should use HTTPS exclusively. If you have an existing app, you should use HTTPS as much as you can right now, and create a plan for migrating the rest of your app as soon as possible.

Add Below key in your info.plist & then see.

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

Even you can add specific exception,

<key>NSAppTransportSecurity</key>
<dict>
    <key>NSExceptionDomains</key>
    <dict>
        <key>testdomain.com</key>
        <dict>
            <key>NSIncludesSubdomains</key>
            <false/>
            <key>NSExceptionAllowInsecureHTTPSLoads</key>
            <false/>
            <key>NSExceptionRequiresForwardSecrecy</key>
            <true/>
            <key>NSExceptionMinimumTLSVersion</key>
            <string>TLSv1.2</string>
            <key>NSThirdPartyExceptionAllowInsecureHTTPSLoads</key>
            <false/>
            <key>NSThirdPartyExceptionRequiresForwardSecrecy</key>
            <true/>
            <key>NSThirdPartyExceptionMinimumTLSVersion</key>
            <string>TLSv1.2</string>
            <key>NSRequiresCertificateTransparency</key>
            <false/>
        </dict>

        ...

    </dict>
</dict>
like image 155
Nilesh Patel Avatar answered Oct 22 '22 06:10

Nilesh Patel


You can follow this easy steps..

Add the following in you info.plist enter image description here

NSAppTransportSecurity
NSAllowsArbitraryLoads
This will help you.

like image 4
Vinu David Jose Avatar answered Oct 22 '22 06:10

Vinu David Jose