Angularjs http.jsonp iOS9 404

给你一囗甜甜゛ 提交于 2019-12-13 05:55:12

问题


I have a Cordova Angularjs app that is getting some JSON from my server. It works on iOS 8, but when I "upgraded" to iOS 9 I am now getting nothing from my server. The server has not been changed, and I can see the JSON response if I navigate to my url.

I narowed it down a little to my $http.jsonp() method. It is giving me a 404 error when trying to retrieve the JSON. The same exact code works fine and gets the JSON on an iOS 8 device.

Anyone else having an issue with this and iOS 9 and have figured any more out? It definitely seems like an Apple related issue...


回答1:


Add this to your info.plist file.

<key>NSAppTransportSecurity</key> 
<dict> 
    <key>NSAllowsArbitraryLoads</key><true/>
</dict>

From 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.

This has been turned on by default in iOS9. They suggest developing using https whenever possible. To get around that you would need the previous code in this answer.



来源:https://stackoverflow.com/questions/32656803/angularjs-http-jsonp-ios9-404

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!