gpt4 book ai didi

ios - Angularjs http.jsonp iOS9 404

转载 作者:行者123 更新时间:2023-11-28 18:30:28 25 4
gpt4 key购买 nike

我有一个 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com