在iOS 9和plist文件上连接到服务器时出现问题

时间:2015-09-02 15:00:26

标签: ios objective-c iphone

我正在努力将我的应用程序更新到ios 9,因为在发送请求时连接到我的服务器时出现问题。它用于显示消息:Transport security has blocked a cleartext HTTP (http://) resource load since it is insecure. Temporary exceptions can be configured via your app's Info.plist file.

所以我已经在plist文件中添加了一些xml代码来解决问题,如另一个stackoverflow帖子中所述... Transport security has blocked a cleartext HTTP

之后,我仍然收到另一个错误:The data could not be read because it isn't in the correct format

我认为这可能是plist文件读取过程中的一些问题,但我也不确定。这是我的应用程序中的错误图片和plist。

enter image description here

enter image description here

enter image description here

1 个答案:

答案 0 :(得分:0)

建议的解决方案应该可行。一定要正确输入。应采用以下形式:

NSAppTransportSecurity     NSAllowsArbitraryLoads     

此外,请注意,这是最常用的选项,因为您可以在表单中添加每个站点的例外:

<key>NSAppTransportSecurity</key>
<dict>
  <key>NSExceptionDomains</key>
  <dict>
    <key>yourserver.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>
</dict>

有关开发论坛的更多信息https://forums.developer.apple.com/thread/3544