Search code examples
iosajaxcordovaibm-mobilefirst

Ajax request not working on iOS 9 in IBM Mobilefirst with cordova project


After upgrade to i0S 9 (and upgrade Mobile first project to 7.1, all request to my server failed. I read about the changes related to iOS 9, but can't find any support for resolve this problem in hybrid applications (Javascript based).

IBM Mobile First, or cordova support that problem?

Everything is fine on Android.


Solution

  • In iOS 9 Apple has introduced what is called Application Transport Security (ATS).
    Yes, this is not related to Android. It is iOS-only.

    Read more about ATS in this blog post, which also contains workarounds for ATS: either setting a whitelist to allow unsecure requests to pass, or disable it completely (for development-time only).

    Note that Hybrid applications already disable it built-in (as mentioned, for development-time. It must be properly configured for production), by adding the following in the application's .plist file. For Native apps you must do this yourself:

    <key>NSAppTransportSecurity</key>
        <dict>
          <key>NSExceptionDomains</key>
          <dict>
            <key>mbp-idan</key>
            <dict>
              <key>NSIncludesSubdomains</key>
              <true/>
              <key>NSTemporaryExceptionAllowsInsecureHTTPLoads</key>
              <true/>
            </dict>
          </dict>
        </dict>
    

    I am using the latest available version which can be downloaded either from IBM Fix Central, or by checking for updates in Eclipse: IBM MobileFirst Platform Studio 7.1.0.00-20150929-1541.

    If you are using an older release, you must upgrade.