ios 9 和 NSAppTransportSecurity
ios 9 and NSAppTransportSecurity
iOS9 和服务器有问题。
我info.plist设置:
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
当您 运行 通过 Xcode 申请时,一切都很好。与服务器的工作完美进行。但是,只要我停止应用程序并尝试 运行 它,只需单击模拟器中的图标即可。网络停止工作。当我将应用程序发送到 TestFlight 中的 Review 时出现同样的问题。应用程序已安装,但网络再次停止工作。
Xcode 7.0 (7a220)
iOS9.0
你确定它不起作用吗?我测试了一下,一切正常。
可能的操作:
启用调试模式,构建您的应用程序,运行 它来自 Xcode 并确保您不 获得 应用程序传输安全错误:
App Transport Security has blocked a cleartext HTTP (http://) resource load since it is insecure.
使用您的模拟器从 Xcode 启动它时。现在找到同一个模拟器DEVICE_CODE
(Hint: it will be one of these ~/Library/Developer/CoreSimulator/Devices/. The easiest way to find this code from Xcode is to go Window->Devices)
并使用 Console 打开它的日志文件:
~/Library/Logs/CoreSimulator/<DEVICE_CODE>/system.log
清除历史记录(以防万一您可以再次从 Xcode 启动您的应用程序并确保您的输出进入您打开的日志文件,并且您仍然没有得到 App Transport Security 那里有错误)。
现在从模拟器启动您的应用程序并检查日志中是否有任何与 App Transport Security 相关的错误。
对我来说,我在 Xcode.
工作时没有 none
==================================
P.S.:
强烈建议不要将 NSAllowsArbitraryLoads 设置为 true,您宁愿通过以下方式获得所需的结果:
<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>
应该是这样的,你需要在你的Plist中添加如下记录
Apple Documentation
它很懒,所以你的框架可以访问 Internet
NSAppTransportSecurity <- 类型字典
NSAllowsArbitraryLoads <- 类型布尔值 YES
非常简单,只需按照以下步骤操作即可:
- 应用程序传输安全设置。
- 允许任意加载。
- 异常域和 domain/host 参考。
注意:出现此问题是因为您的项目设置在默认情况下不允许任何跨站点脚本引用。因此,它会阻止任何在您的应用程序之外进行的服务调用。
iOS9 和服务器有问题。 我info.plist设置:
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
当您 运行 通过 Xcode 申请时,一切都很好。与服务器的工作完美进行。但是,只要我停止应用程序并尝试 运行 它,只需单击模拟器中的图标即可。网络停止工作。当我将应用程序发送到 TestFlight 中的 Review 时出现同样的问题。应用程序已安装,但网络再次停止工作。
Xcode 7.0 (7a220) iOS9.0
你确定它不起作用吗?我测试了一下,一切正常。
可能的操作:
启用调试模式,构建您的应用程序,运行 它来自 Xcode 并确保您不 获得 应用程序传输安全错误:
App Transport Security has blocked a cleartext HTTP (http://) resource load since it is insecure.
使用您的模拟器从 Xcode 启动它时。现在找到同一个模拟器DEVICE_CODE
(Hint: it will be one of these ~/Library/Developer/CoreSimulator/Devices/. The easiest way to find this code from Xcode is to go Window->Devices)
并使用 Console 打开它的日志文件:
~/Library/Logs/CoreSimulator/<DEVICE_CODE>/system.log
清除历史记录(以防万一您可以再次从 Xcode 启动您的应用程序并确保您的输出进入您打开的日志文件,并且您仍然没有得到 App Transport Security 那里有错误)。
现在从模拟器启动您的应用程序并检查日志中是否有任何与 App Transport Security 相关的错误。
对我来说,我在 Xcode.
工作时没有 none==================================
P.S.:
强烈建议不要将 NSAllowsArbitraryLoads 设置为 true,您宁愿通过以下方式获得所需的结果:
<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>
应该是这样的,你需要在你的Plist中添加如下记录 Apple Documentation
它很懒,所以你的框架可以访问 Internet
NSAppTransportSecurity <- 类型字典
NSAllowsArbitraryLoads <- 类型布尔值 YES
非常简单,只需按照以下步骤操作即可:
- 应用程序传输安全设置。
- 允许任意加载。
- 异常域和 domain/host 参考。
注意:出现此问题是因为您的项目设置在默认情况下不允许任何跨站点脚本引用。因此,它会阻止任何在您的应用程序之外进行的服务调用。