Angularjs http.jsonp iOS9 404
Angularjs http.jsonp iOS9 404
我有一个 Cordova Angularjs 应用程序正在从我的服务器获取一些 JSON。它适用于 iOS 8,但是当我从 "upgraded" 到 iOS 9 时,我现在从我的服务器上什么也得不到。服务器没有更改,如果我导航到 url.
,我可以看到 JSON 响应
我将其缩小到我的 $http.jsonp() 方法。尝试检索 JSON 时出现 404 错误。完全相同的代码工作正常,并在 iOS 8 设备上获得 JSON。
还有其他人对此有疑问并且 iOS 9 已经想通了吗?这绝对像是一个与 Apple 相关的问题...
将此添加到您的 info.plist
文件中。
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key><true/>
</dict>
App Transport Security (ATS) enforces best practices in the secure connections between an app and its back end. ATS prevents accidental disclosure, provides secure default behavior, and is easy to adopt; it is also on by default in iOS 9 and OS X v10.11. You should adopt ATS as soon as possible, regardless of whether you’re creating a new app or updating an existing one.
If you’re developing a new app, you should use HTTPS exclusively. If you have an existing app, you should use HTTPS as much as you can right now, and create a plan for migrating the rest of your app as soon as possible. In addition, your communication through higher-level APIs needs to be encrypted using TLS version 1.2 with forward secrecy. If you try to make a connection that doesn't follow this requirement, an error is thrown. If your app needs to make a request to an insecure domain, you have to specify this domain in your app's Info.plist file.
这已在 iOS9 中默认打开。他们建议尽可能使用 https 进行开发。要解决这个问题,您需要此答案中的先前代码。
我有一个 Cordova Angularjs 应用程序正在从我的服务器获取一些 JSON。它适用于 iOS 8,但是当我从 "upgraded" 到 iOS 9 时,我现在从我的服务器上什么也得不到。服务器没有更改,如果我导航到 url.
,我可以看到 JSON 响应我将其缩小到我的 $http.jsonp() 方法。尝试检索 JSON 时出现 404 错误。完全相同的代码工作正常,并在 iOS 8 设备上获得 JSON。
还有其他人对此有疑问并且 iOS 9 已经想通了吗?这绝对像是一个与 Apple 相关的问题...
将此添加到您的 info.plist
文件中。
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key><true/>
</dict>
App Transport Security (ATS) enforces best practices in the secure connections between an app and its back end. ATS prevents accidental disclosure, provides secure default behavior, and is easy to adopt; it is also on by default in iOS 9 and OS X v10.11. You should adopt ATS as soon as possible, regardless of whether you’re creating a new app or updating an existing one.
If you’re developing a new app, you should use HTTPS exclusively. If you have an existing app, you should use HTTPS as much as you can right now, and create a plan for migrating the rest of your app as soon as possible. In addition, your communication through higher-level APIs needs to be encrypted using TLS version 1.2 with forward secrecy. If you try to make a connection that doesn't follow this requirement, an error is thrown. If your app needs to make a request to an insecure domain, you have to specify this domain in your app's Info.plist file.
这已在 iOS9 中默认打开。他们建议尽可能使用 https 进行开发。要解决这个问题,您需要此答案中的先前代码。