Android 通过Play Store下载后,Cordova应用程序无法使用互联网

Android 通过Play Store下载后,Cordova应用程序无法使用互联网,android,cordova,Android,Cordova,昨天在Play Store上发布了一个新应用程序。几个月来,我们一直在使用/测试该应用程序,但从Play Store下载的版本无法访问互联网。从Cordova CLI运行应用程序时从未出现此问题 该应用程序在启动时有一个连接到服务器的登录页面-我可以在应用程序设置中看到该应用程序根本没有使用任何数据,并且在应用程序或日志目录adb logcat中没有抛出任何错误 有什么问题吗?详情如下: 测试设备 HTC10安卓7.0 谷歌像素安卓7.1.2 Config.xml 显示 身份验证控制器 来自lo

昨天在Play Store上发布了一个新应用程序。几个月来,我们一直在使用/测试该应用程序,但从Play Store下载的版本无法访问互联网。从Cordova CLI运行应用程序时从未出现此问题

该应用程序在启动时有一个连接到服务器的登录页面-我可以在应用程序设置中看到该应用程序根本没有使用任何数据,并且在应用程序或日志目录adb logcat中没有抛出任何错误

有什么问题吗?详情如下:

测试设备

HTC10安卓7.0 谷歌像素安卓7.1.2 Config.xml

显示

身份验证控制器

来自logcat的控制台


终于找到了答案

Ajax请求被阻止到HTTPS,因为我使用的是自签名SSL证书

虽然不建议这样做,但您应该使用有效的证书进行生产,这里有一个快速的方法

安装cordova插件证书 cordova.plugins.certificates.trustUnsecureCertstrue;在提出请求之前
<uses-sdk android:minSdkVersion="16" android:targetSdkVersion="25" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission android:name="${applicationId}.permission.C2D_MESSAGE" />
<uses-permission android:name="${applicationId}.permission.PushHandlerActivity" />
<permission android:name="${applicationId}.permission.C2D_MESSAGE" android:protectionLevel="signature" />
<permission android:name="${applicationId}.permission.PushHandlerActivity" android:protectionLevel="signature" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<meta http-equiv="Content-Security-Policy" content="default-src * gap://ready; connect-src * ws: wss:; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; img-src 'self' data: *">
 login: function(un, pw, onProgress, onSuccess, onAbort, onError) {
    var params = {
        username: un,
        password: pw,
    };

    var httpHeaders = {
        'X-CSRF-Token': app.token
    };

    app.authRemote.restClient.call(config.serverURL + '/' + config.serviceEndPoint + '/endpoint/login', JSON.stringify(params), {requestMethod: 'POST', requestDataType: 'application/json', httpHeaders: httpHeaders, responseDataType: 'json'},
        function _onProgress() {
            onProgress(app.authRemote.restClient);
        },
        function _onSuccess(result) {
            onSuccess(result);
        },
        function _onAbort() {
            onAbort();
        },
        function _onError(error) {
            onError(error);
        }
    );
},
this.login = function(username, password, onSuccess, onError){
    app.authRemote.login(username, password,
        function _onProgress(restClient) {
            console.log('Sent = ' + restClient.bytesSent + ' | received = ' + restClient.bytesReceived);
        },
        function _onSuccess(data) {
            onSuccess(data);
        },
        function _onAbort() {
        },
        function _onError(error) {

            onError(error);
        }
    );
};
 07-14 11:03:52.092 18738 18738 D SystemWebChromeClient: file:///android_asset/www/js/modules/system/controllers/auth-controller.js: Line 670 : Sent = 0 Bytes | received = 0 Bytes