NSURLSession/NSURLConnection HTTP 加载在设备 9.0 上失败



我正在使用cordova/ionic开发一个应用程序,但自从iOS 9更新以来,我无法部署到设备上。我的应用程序在模拟器上运行,但是无论我尝试什么,当我部署到设备时,我都会收到相同的错误。我知道有很多关于这个问题的帖子,但没有一个能够解决我的问题。

是否有人使用相同的平台(ionic/cordova)遇到相同的问题。

这是我的 .plist 的样子:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
  <dict>
    <key>CFBundleDevelopmentRegion</key>
    <string>English</string>
    <key>CFBundleDisplayName</key>
    <string>${PRODUCT_NAME}</string>
    <key>CFBundleExecutable</key>
    <string>${EXECUTABLE_NAME}</string>
    <key>CFBundleIcons</key>
    <dict/>
    <key>CFBundleIcons~ipad</key>
    <dict/>
    <key>CFBundleIdentifier</key>
    <string>io.cordova.myappff160c</string>
    <key>CFBundleInfoDictionaryVersion</key>
    <string>6.0</string>
    <key>CFBundleName</key>
    <string>${PRODUCT_NAME}</string>
    <key>CFBundlePackageType</key>
    <string>APPL</string>
    <key>CFBundleShortVersionString</key>
    <string>1.0.6</string>
    <key>CFBundleSignature</key>
    <string>????</string>
    <key>CFBundleVersion</key>
    <string>1.0.6</string>
    <key>LSRequiresIPhoneOS</key>
    <true/>
    <key>NSMainNibFile</key>
    <string/>
    <key>NSMainNibFile~ipad</key>
    <string/>
    <key>UISupportedInterfaceOrientations</key>
    <array>
      <string>UIInterfaceOrientationPortrait</string>
      <string>UIInterfaceOrientationPortraitUpsideDown</string>
    </array>
    <key>UISupportedInterfaceOrientations~ipad</key>
    <array>
      <string>UIInterfaceOrientationPortrait</string>
      <string>UIInterfaceOrientationPortraitUpsideDown</string>
    </array>
    <key>UIRequiresFullScreen</key>
    <true/>
    <key>NSAppTransportSecurity</key>
    <dict>
      <key>NSAllowsArbitraryLoads</key>
      <true/>
      <key>NSExceptionDomains</key>
      <dict>
        <key>m.facebook.com</key>
        <dict/>
        <key>graph.facebook.com</key>
        <dict/>
        <key>api.facebook.com</key>
        <dict/>
        <key>fbcdn.net</key>
        <dict>
          <key>NSIncludesSubdomains</key>
          <true/>
        </dict>
        <key>akamaihd.net</key>
        <dict>
          <key>NSIncludesSubdomains</key>
          <true/>
        </dict>
      </dict>
    </dict>
    <key>UIInterfaceOrientation</key>
    <array>
      <string>UIInterfaceOrientationPortrait</string>
    </array>
    <key>FacebookAppID</key>
    <string>xxxxxxxxxxxxxx</string>
    <key>FacebookDisplayName</key>
    <string>Birdy.life</string>
    <key>CFBundleURLTypes</key>
    <array>
      <dict>
        <key>CFBundleURLSchemes</key>
        <array>
          <string>fb1074874362552202</string>
        </array>
      </dict>
    </array>
    <key>NSLocationWhenInUseUsageDescription</key>
    <string/>
    <key>UIBackgroundModes</key>
    <array>
      <string>remote-notification</string>
    </array>
  </dict>
</plist>

这是我部署到设备时得到的输出:

2016-05-30 17:31:53.465 Birdy[1102:584334] Apache Cordova native platform version 4.1.1 is starting.
2016-05-30 17:31:53.468 Birdy[1102:584334] Multi-tasking -> Device: YES, App: YES
2016-05-30 17:31:53.576 Birdy[1102:584334] Using UIWebView
2016-05-30 17:31:53.581 Birdy[1102:584334] [CDVTimer][handleopenurl] 0.264049ms
2016-05-30 17:31:53.588 Birdy[1102:584334] Unlimited access to network resources
2016-05-30 17:31:53.590 Birdy[1102:584334] [CDVTimer][intentandnavigationfilter] 7.857978ms
2016-05-30 17:31:53.591 Birdy[1102:584334] [CDVTimer][gesturehandler] 0.279963ms
2016-05-30 17:31:53.592 Birdy[1102:584334] Starting Facebook Connect plugin
2016-05-30 17:31:53.593 Birdy[1102:584334] [CDVTimer][facebookconnectplugin] 1.308978ms
2016-05-30 17:31:53.626 Birdy[1102:584334] [CDVTimer][splashscreen] 32.754004ms
2016-05-30 17:31:53.663 Birdy[1102:584334] [CDVTimer][localstorage] 35.548985ms
2016-05-30 17:31:53.664 Birdy[1102:584334] [CDVTimer][TotalPluginStartup] 84.178030ms
2016-05-30 17:31:53.973 Birdy[1102:584334] Resetting plugins due to page load.
2016-05-30 17:31:55.337 Birdy[1102:584398] NSURLSession/NSURLConnection HTTP load failed (kCFStreamErrorDomainSSL, -9813)
2016-05-30 17:31:55.340 Birdy[1102:584398] NSURLSession/NSURLConnection HTTP load failed (kCFStreamErrorDomainSSL, -9813)
2016-05-30 17:31:55.448 Birdy[1102:584398] NSURLSession/NSURLConnection HTTP load failed (kCFStreamErrorDomainSSL, -9813)
2016-05-30 17:31:55.711 Birdy[1102:584334] Finished load of: file:///var/containers/Bundle/Application/F5E4D8B5-7A45-4DA7-B7CE-CFC12DB7A5FF/Birdy.app/www/index.html#/public/home
2016-05-30 17:31:56.066 Birdy[1102:584392] NSURLSession/NSURLConnection HTTP load failed (kCFStreamErrorDomainSSL, -9813)
2016-05-30 17:31:56.126 Birdy[1102:584392] NSURLSession/NSURLConnection HTTP load failed (kCFStreamErrorDomainSSL, -9813)
2016-05-30 17:31:58.309 Birdy[1102:584398] NSURLSession/NSURLConnection HTTP load failed (kCFStreamErrorDomainSSL, -9813)

我唯一看到的是启动画面,仅此而已。我错过了什么还是忽略了它?

我建议您在NSAppTransportSecurity Info.plist设置中尝试此操作。 您收到的错误表明您的服务器未使用最新和最好的 TLS,或者以某种方式以其他方式配置错误。 我相信当你开始指定比我下面更多的内容时,你实际上限制了事情,而不是让它们敞开(我认为这是你想要的)。

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

最新更新