PhoneGap 构建 - Config.XML - REST CALL 由于 'ConnectionError' 而失败
PhoneGap build - Config.XML - REST CALL fails due to 'ConnectionError'
我已经使用自定义的 PhoneGap build 构建了一个应用程序 Config.xml
:
<?xml version='1.0' encoding='utf-8'?>
<widget xmlns = "http://www.w3.org/ns/widgets"
xmlns:gap = "http://phonegap.com/ns/1.0"
id = "com.package"
versionCode = "25"
version = "1.0.1" >
<name>TEST APP</name>
<description>TEST APP</description>
<icon src="res/img/icon.png" />
<icon src="res/img/icon.png" platform="android" density="ldpi" />
<icon src="res/img/icon.png" platform="android" density="mdpi" />
<icon src="res/img/icon.png" platform="android" density="hdpi" />
<icon src="res/img/icon.png" platform="android" density="xhdpi" />
<feature name="http://api.phonegap.com/1.0/network" />
<feature name="http://api.phonegap.com/1.0/file" />
<feature name="http://api.phonegap.com/1.0/device" />
<gap:plugin name="cordova-plugin-whitelist" source="npm" version="1.0.0" />
<access origin="*" />
<allow-intent href="*" />
<allow-navigation href="*" />
</widget>
向 index.html 添加了内容安全策略:
<meta http-equiv="Content-Security-Policy" content="default-src *; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline' 'unsafe-eval'">
构建没有中断 - 应用程序已提交到 PlayStore
在 HTTPS link 上从应用程序触发 REST 调用时出现错误:
return status '0' / return status text ''
该应用程序在浏览器中本地正确运行,因此在 REST/APP 级别没有问题。
我感觉这与某些缺少的配置有关?
欢迎任何帮助!
@dann,
您没有告诉 phonegap build 要构建哪个版本。如:
<preference name="phonegap-version" value="3.5.0" />
由于您没有列出此 "preference",您获得的是最新版本。
另外,在最新版本的 phonegap 中使用白名单时,我被告知您需要向 config.xml 添加更多信息。为此,您需要参考主示例 https://github.com/phonegap/phonegap-start/blob/master/www/config.xml
您可能需要添加插件
<plugin name="cordova-plugin-whitelist" version="1" />
如果您想限制白名单而不是现在的广泛参考,请阅读
白名单指南
http://docs.phonegap.com/en/4.0.0/guide_appdev_whitelist_index.md.html#Whitelist%20Guide
更多关于白名单的帮助,推荐google群:
https://groups.google.com/forum/#!forum/phonegap
有关Phonegap Build的更多帮助,我推荐官方论坛
http://community.phonegap.com/nitobi
我已经使用自定义的 PhoneGap build 构建了一个应用程序 Config.xml
:
<?xml version='1.0' encoding='utf-8'?>
<widget xmlns = "http://www.w3.org/ns/widgets"
xmlns:gap = "http://phonegap.com/ns/1.0"
id = "com.package"
versionCode = "25"
version = "1.0.1" >
<name>TEST APP</name>
<description>TEST APP</description>
<icon src="res/img/icon.png" />
<icon src="res/img/icon.png" platform="android" density="ldpi" />
<icon src="res/img/icon.png" platform="android" density="mdpi" />
<icon src="res/img/icon.png" platform="android" density="hdpi" />
<icon src="res/img/icon.png" platform="android" density="xhdpi" />
<feature name="http://api.phonegap.com/1.0/network" />
<feature name="http://api.phonegap.com/1.0/file" />
<feature name="http://api.phonegap.com/1.0/device" />
<gap:plugin name="cordova-plugin-whitelist" source="npm" version="1.0.0" />
<access origin="*" />
<allow-intent href="*" />
<allow-navigation href="*" />
</widget>
向 index.html 添加了内容安全策略:
<meta http-equiv="Content-Security-Policy" content="default-src *; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline' 'unsafe-eval'">
构建没有中断 - 应用程序已提交到 PlayStore 在 HTTPS link 上从应用程序触发 REST 调用时出现错误:
return status '0' / return status text ''
该应用程序在浏览器中本地正确运行,因此在 REST/APP 级别没有问题。
我感觉这与某些缺少的配置有关?
欢迎任何帮助!
@dann, 您没有告诉 phonegap build 要构建哪个版本。如:
<preference name="phonegap-version" value="3.5.0" />
由于您没有列出此 "preference",您获得的是最新版本。
另外,在最新版本的 phonegap 中使用白名单时,我被告知您需要向 config.xml 添加更多信息。为此,您需要参考主示例 https://github.com/phonegap/phonegap-start/blob/master/www/config.xml
您可能需要添加插件
<plugin name="cordova-plugin-whitelist" version="1" />
如果您想限制白名单而不是现在的广泛参考,请阅读
白名单指南
http://docs.phonegap.com/en/4.0.0/guide_appdev_whitelist_index.md.html#Whitelist%20Guide
更多关于白名单的帮助,推荐google群:
https://groups.google.com/forum/#!forum/phonegap
有关Phonegap Build的更多帮助,我推荐官方论坛
http://community.phonegap.com/nitobi