Ped*_*lis 11 android http apk cordova ionic-framework
我正努力让我的应用程序在Android APK版本上运行,唯一的失败方案是生成并签署apk.所有http请求都不起作用.(服务器在SSL下运行)
我已经尝试过的所有场景:
ionic serve - >工作正常.ionic cordova run android --device - >工作正常.也适用于生成iOS版本:
ionic cordova build ios.因此,唯一不起作用的情况是当我尝试通过ionic cordova build android --prod --release签名生成它的apk 时.
Google Play也接受新的APK,因此套餐标志完全没问题.
由于它适用于iOS并直接在Android设备上运行,因此它不是CORS或HTTPS证书问题.
代码:
login.ts的片段:
this.userService.loginUser(this.user).then(
(data) => {
let response = data.json();
loading.dismiss().then(loadData => {
if (response.access_token) {
this.global.access_token = response.access_token;
this.getUserData();
}
});
}, err => {
let error = err.json();
loading.dismiss().then(response => {
if (error.message) {
this.showToast(error.message, 3000, 'bottom');
}
});
}
);
Run Code Online (Sandbox Code Playgroud)
userService.loginUser方法:
loginUser(data) {
let headers = new Headers();
headers.append('Access-Control-Allow-Origin', '*');
headers.append('auth-token', '*');
return this.abs.post('/authenticateMobile',
{
login_ds_email: data.email,
login_ds_password: data.pass
}, headers);
}
Run Code Online (Sandbox Code Playgroud)
在哪里abs:
constructor(http) {
this.abs = new ApiService(http);
}
Run Code Online (Sandbox Code Playgroud)
ApiService.post方法:
public post(api, params, header): any {
if (!header) {
header = this.getHeaders();
}
let options = new RequestOptions({headers: header});
let url = this.global.urlGlobal + api;
return this.http.post(url, params, options).toPromise();
}
Run Code Online (Sandbox Code Playgroud)
当我点击"登录"按钮并发出请求时,应用程序卡住了.服务器没有抛出任何异常,因此加载屏幕将永久显示.
我已经没有这方面的解决方案,我希望你们可以帮助我.
离子信息:
global packages:
@ionic/cli-utils : 1.4.0
Cordova CLI : 6.4.0
Gulp CLI : CLI version 3.9.1 Local version 3.9.1
Ionic CLI : 3.4.0
local packages:
@ionic/app-scripts : 1.3.0
@ionic/cli-plugin-cordova : 1.4.0
@ionic/cli-plugin-gulp : 1.0.1
@ionic/cli-plugin-ionic-angular : 1.3.1
Cordova Platforms : android 6.0.0 ios 4.3.1
Ionic Framework : ionic-angular 3.0.1
System:
Node : v7.8.0
OS : macOS Sierra
Xcode : Xcode 8.3.3 Build version 8E3004b
ios-deploy : 1.9.0
ios-sim : 5.0.6
npm : 5.0.3
Run Code Online (Sandbox Code Playgroud)
And*_*ann 15
前段时间我有同样的问题.在我的情况下,问题是无效的证书.在iOS上和在Android上测试时,证书在浏览器中看起来很好(chrome甚至显示绿色锁定).但我有Android用户抱怨它不适合他们.
经过几个小时的研究后发现,对具有无效证书的网站的请求只是默默地丢弃,这意味着没有任何反馈意见.没有错误,没有.(如果我没记错的话,js代码只是在没有返回或执行任何回调的情况下停止执行.)仅在构建发布模式时才会发生这种情况.
此处描述了一种解决方法:
http://ivancevich.me/articles/ignoring-invalid-ssl-certificates-on-cordova-android-ios/
处理它的最佳方法是将证书固定在您的应用程序中.
我的问题是不完整的 SSL 链,通过重新配置 nginx 以拥有整个 SSL 证书链来解决它,如下所述:http : //nginx.org/en/docs/http/configuring_https_servers.html#chains
我的问题也出在 SSL 上。如果您从该网站获得“A+”评级,则该网站应该有效。我原来的成绩是“B”。 https://www.ssllabs.com/ssltest
您可以使用此网站来纠正它。 https://whatsmychaincert.com/
| 归档时间: |
|
| 查看次数: |
7476 次 |
| 最近记录: |