ios - Angularjs http.jsonp iOS9 404

标签 ios angularjs cordova http jsonp

我有一个 Cordova Angularjs 应用程序,它从我的服务器获取一些 JSON。它适用于 iOS 8,但是当我“升级”到 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>

来自 this page

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 进行开发。要解决这个问题,您需要此答案中的先前代码。

关于ios - Angularjs http.jsonp iOS9 404,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32656803/

相关文章:

iOS 查看尺寸 iPad

AngularJS:基于结果的 promise 和条件

java - 黑莓应用程序开发

javascript - OnSen UI 滑动菜单未出现

android - 如何从 Ionic/Angularjs 项目中的 localStorage 检索用户详细信息

iOS - 无法将 NSString 对象添加到 NSMutableSet

ios - 可拖动标签 - ios

ios - pageCurl 动画与触摸交互

css - 动画 ng-repeat on Remove

css - 当我将鼠标悬停在工具提示上时看到在 html 中编写的脚本