科尔多瓦:Ajax调用不工作在iOS上,正常工作在Android [英] Cordova: Ajax call not working on iOS, works fine on Android

查看:106
本文介绍了科尔多瓦:Ajax调用不工作在iOS上,正常工作在Android的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我与科尔多瓦首次(不PhoneGap的!),和我的应用程序工作正常,在Android上,但不能访问外部服务器上的iOS Ajax调用。 我加了

I'm working with Cordova for the first time (not Phonegap!) and my app works fine on Android but can't access the external server for ajax calls on iOS. I added

<access origin="*" />

在没有任何成功的config.xml文件。所有的解决方案,我能找到的PhoneGap的唯一的工作。有谁知道如何解决这个问题?也许甚至是在X code置?太谢谢你了!

to the config.xml without any success. All solutions I could find only work in Phonegap. Does anyone know how to fix that problem? Maybe even a setting in Xcode? Thank you so much!

推荐答案

@Ben,
在过去的二(2)周科尔多瓦已经做出了一些重大变化。该文档已没有跟上。我不希望它会赶上,至少几个星期。你有两个(2)选项:

@Ben,
over the last two (2) weeks Cordova has made some major changes. The documentation has NOT caught up. I don't expect it will catch up for at least a few weeks. You have two (2) options:

  1. 在科尔多瓦4.0.0之前,请将您的编译器版本的东西
  2. 按照完整的协议,使用白名单

我推荐#2。

热门误判开发新科尔多瓦/ PhoneGap的你已经一:

  • #6 不设置的PhoneGap版为你的编译器
  • #7的未设置版为你插件
  • #10 不增加新的白名单和白名单插件config.xml中的参数。
  • #6 Not setting the "phonegap version" for your compiler
  • #7 Not setting "version" for you plugins
  • #10 Not adding the new "white-list" and "white-list plugin" parameters in config.xml.

有关#6安培; #7

For #6 & #7

通过CLI版本,如果你不为你的平台,或在''的PhoneGap构建''如果你不设置的PhoneGap版本config.xml中,您将获得最新的版本分配一个版本。如果你够幸运,你的程序仅仅按预期工作。如果你不走运,你会得到一组级联的错误。

With the CLI version, if you do not assign a version for your platform OR in ''Phonegap Build'' if you do not set the phonegap-version in config.xml, YOU WILL GET THE LATEST VERSION. If you are lucky, your program just works as expected. If you are not lucky, you'll get a set of cascading errors.

幸运的是,我们所有的人,冬青Schinsky提供写一篇好的博客贴子来解释这一切:

Luckily for all of us, Holly Schinsky has written a nice blog post to explain it all:

科尔多瓦/ PhoneGap的版本混乱
   http://devgirl.org/2014/11/07/cordovaphonegap-version-混乱/

Cordova/PhoneGap Version Confusion
http://devgirl.org/2014/11/07/cordovaphonegap-version-confusion/

有关#10

此相对*新*要求意味着&ndash的;访问任何网站或资源,在网络上,则必须使用白名单和白名单的插件。此要求进入的影响,如果你使用的是cordova-android@4.0.0或更好;包括CLI-5.1.1和CLI-5.2.0。但是,如果你的版本是4.0.0之前,让我们说3.5.0或3.7.0,那么你会的没有的必须添加的白名单的要求。

This relatively * NEW * requirement means – to access ANY website or resources on the web, you MUST use the whitelist and the whitelist plugin. This requirement goes into affect, if you are using cordova-android@4.0.0 or better; including cli-5.1.1 and cli-5.2.0. If however, your version is before 4.0.0, let's say 3.5.0 or 3.7.0, then you will not have to add the white-list requirement.

需要明确的是,在白名单已经出现了一点,但这个插件和要求是非常新的。正如你所期望的,白名单中添加的时候,事实上的开放式访问功能是pcated德$ P $。或者说另一种方式,事实上的开放式访问功能,计划和预定被淘汰。这种变化标志着去除开放式访问功能的步骤。

To be clear, the "whitelist" has been around for a bit, but the plugin and requirement is very new. As you would expect, when the "whitelist" was added, the defacto open-access feature was deprecated. Or said another way, the defacto open-access feature was planned and scheduled to be eliminated. This change marks a step in removal of the open-access feature.

在此外,内容安全策略(CSP)已经引起许多开发者 - 因为它被SOOOO公布很差。 根据您的使用和PhoneGap的你正在使用的版本,在CSP需要去您使用的每一个HTML页面,就像你必须等待'deviceready。但是,也有在那里它不需要在所有的情况下。是混淆了一些文件,请仔细阅读。该文档被埋没在众多的最新文档页面的底部。

In addition, the Content Security Policy (CSP) has caught numerous developers - because it was soooo poorly publicized. Depending on your use and the version of Phonegap you are using, the CSP needs to go in every single HTML page you used, just like you have to wait for 'deviceready'. However, there are cases where it is not needed at all. The documentation is confusing for some, please read it carefully. The documentation is buried in the bottom of many of the latest documentation pages.

相关链接

的PhoneGap构建论坛:的注意升级到CLI-5.1.1上PGB 现在需要白名单

Phonegap Build Forum: Notes for upgrading to cli-5.1.1 on PGB and now required Whitelist

  • Cordova Whitelist Guide
  • Phonegap Whitelist Guide
  • Phonegap Build Whitelist Guide
  • White-list Plugin - READ BOTTOM section for instruction on CSP

这篇关于科尔多瓦:Ajax调用不工作在iOS上,正常工作在Android的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆