【问题标题】:No network connection w/ Phonegap build app没有使用 Phonegap 构建应用程序的网络连接
【发布时间】:2016-08-22 18:45:46
【问题描述】:

我正在努力将较旧的应用程序更新为较新版本的 phonegap api。我正在努力让网络访问工作。

我已更改 config.xml 以删除功能块并添加了插件 cordova-plugin-whitelist。我还在 config.xml 文件中添加了以下内容。

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

我还在索引文件中添加了内容安全元标记。

<meta http-equiv="Content-Security-Policy" content="default-src *; style-src *  'unsafe-inline'; script-src *  'unsafe-inline'; media-src *">

网络检查报告“未知”。

var networkState = navigator.connection.type;
alert('Connection type: ' + networkState);

我还注意到应用权限没有列出网络访问权限。

有人知道什么会导致这种情况吗?

【问题讨论】:

  • 在您的 AndroidMainfest.xml 中添加以下行权限:

标签: android cordova phonegap-build


【解决方案1】:

使用Cordova plugin add cordova-plugin-network-information 然后window.Connection 检查可用的互联网。

var myNetwork=navigator.connection.type;
console.log(myNetwork);
alert(myNetwork);

【讨论】:

  • 感谢您的信息。我的 config.xml 中已经有 用于 phonegap 构建。
  • 是否显示在 androidmanifest 文件中?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-07-28
  • 2012-02-22
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多