Failed http connection in iOS 9

In iOS apps, http connection is always fail from iOS 9, because of the access server does not contain App Transport Security(ATS).

What's happened?

  • The return value of NSString stringWithContentsOfURL is null
  • UIWebView loadRequest, and then nothing.
  • They are nothing happened under iOS 9 devices.

Conditions

  • Builds for iOS 9 and Runs on iOS 9 devices
  • It is particular URL.

What should I do?

Set the domain name you don't want to use ATS to info.plist.

Xcode - Open As Property List

- Change blabla.com to any domain you want.

Xcode - Open As Source Code
    <key>NSAppTransportSecurity</key>
    <dict>
        <key>NSExceptionDomains</key>
        <dict>
            <key>blabla.com</key>
            <dict>
                <key>NSTemporaryExceptionAllowsInsecureHTTPLoads</key>
                <true/>
            </dict>
        </dict>
    </dict>

Ref Link

https://developer.apple.com/library/ios/documentation/General/Reference/InfoPlistKeyReference/Articles/CocoaKeys.html#//apple_ref/doc/uid/TP40009251-SW33