【问题标题】:Phonegap Android Ajax Stopped WorkingPhonegap Android Ajax 停止工作
【发布时间】:2016-10-28 07:18:29
【问题描述】:

我更新了 phonegap build 6.3.4 (Cordova 6.4.0)。到目前为止,对服务器的所有 ajax 调用都运行良好。它突然停止了。

我在 iOS 构建中遇到了类似的情况,它变成了 Content-Security-Policy 的新增内容。我想知道是否为 Android 添加了任何内容?

最后,是否有关于要添加的内容安全标签的适当信息?

插件

cordova-plugins-whitelist

config.xml

    <access origin="http://*" />
    <access origin="https://*" />
    <allow-navigation href="*" />
    <allow-intent href="*" />

index.html

<meta http-equiv="Content-Security-Policy" content="img-src * 'self' data:; default-src * 'self' gap: wss: ws: ; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline' 'unsafe-eval';">

【问题讨论】:

  • 尝试使用白名单插件https://cordova.apache.org/docs/en/latest/reference/cordova-plugin-whitelist/ 并允许您的域
  • &lt;allow-navigation href="http://example.com/*" /&gt;&lt;allow-navigation href="http://*/*" /&gt;
  • 嗨,我已经有 cordova-plugin-whitelist .. 但我没有在允许导航中添加所有域
  • 您尝试过添加导航吗?它对您有用吗?
  • 对不起,如果我之前没有说清楚。我已经安装了cordova-plugin-whitelist。这个标签存在于我的配置中 这一直有效,直到最后一次构建(大约一周前)

标签: android jquery ajax cordova phonegap-build


【解决方案1】:

当您完成所有操作但 ajax 仍然无法正常工作时,是时候查看您的 SSL。让我惊叹的时刻是应用程序在调试模式下工作但不在发布模式下。

这导致了这个线程here。由于错误的 SSL 实现,Android 没有检测到证书。

在调试模式下,android 会覆盖 SSL 问题(因此它起作用了)。在发布模式下,它静默失败并导致问题。

我更新了根证书/中间证书/站点证书来解决它

【讨论】:

    猜你喜欢
    • 2017-08-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-06-28
    相关资源
    最近更新 更多