[英]Cordova app cannot use internet after downloading via Play Store
Published a new app yesterday on Play Store been using/testing the app for months without a problem now but the version downloaded from the play store cannot access the internet (assumption). 昨天在Play商店上发布了一个新的应用程序,该应用程序已经使用/测试了几个月,现在没有问题,但是从Play商店下载的版本无法访问互联网(假设)。 Never had this issue while running the app from Cordova CLI.
在运行从科尔多瓦CLI应用程序从未有过这个问题。
The app has a login page at launch which connects to a server - I can see in the app settings the app hasn't used any data at all and no errors are thrown in the app or the log cat ( adb logcat
). 该应用程序在启动时有一个登录页面,该页面连接到服务器-我可以在应用程序设置中看到该应用程序根本没有使用任何数据,并且在该应用程序或log cat(
adb logcat
)中没有引发任何错误。
What could be the problem? 可能是什么问题呢? Details as follows;
详情如下;
Tested Devices 测试的设备
Config.xml Config.xml
<access origin="*" />
Manifest 表现
<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" />
CSP CSP
<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: *">
Auth Model 验证模型
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);
}
);
},
Auth Controller 验证控制器
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);
}
);
};
Console from logcat 从logcat控制台
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
Actually found the answer to this finally... 终于找到答案了……
Ajax requests were being blocked to HTTPS
because I'm using a self-signed SSL
certificate. 由于我使用的是自签名
SSL
证书,因此Ajax请求被阻止访问HTTPS
。
Although it is not recommended to do this (you should use a valid certificate for production), here is a quick way around; 尽管不建议这样做(您应该使用有效的证书进行生产),但这是一种快速的方法。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.