Pixel 2 API 29 httpClient无法正常工作

时间:2019-07-19 18:36:38

标签: nativescript nativescript-angular

我终于向商店发布了nativescript应用。 iOS很好,几乎所有版本的Android都很好。但是,有人下载了使用API​​ 29的Pixel 2,并告诉我他们无法登录。我下载了一个仿真器,而且可以肯定的是,http请求永远不会通过。

这是我在服务中的登录代码:

getLogin(args): RxObservable<Object> {
    var params = this.buildQueryParams(args);
    let headers = this.createRequestHeader();
    return this.http.get(`${this.serverUrl}AuthenticateUser${params}`);
}

这是我使用它的登录组件:

login() {
  this.isLoggingIn = true;
  Object.assign(this.user, this.loginForm.value);
  this.httpSub = this.httpget.getLogin(this.user)
  .pipe(
    map(res=>res),
    catchError((err: string) => {
      const errMsg = "There was a network error, please check your connection or try again later";
      return of(errMsg)
  })
)
  .subscribe((result) => {
    if(result['Status'] === "SUCCESS"){
      this.onGetDataSuccess(result);
    }
    else if(typeof(result) === 'string'){
      this.errorMessage = "There is a connection error.";
      this.isLoggingIn = false;
    }
    else {
      this.errorMessage = "user name or password incorrect";
      this.isLoggingIn = false;
    }
}, (error) => {
  console.log("got an error");
    this.errorMessage = "Verify your username and password.  If you have an account, but are having trouble, call 1-866-706-8665.";
    this.isLoggingIn = false;
});

我在Pixel上得到了这个

存在连接错误。

在调试器中,这是我在像素标题上看到的:

Request URL: http://toolingu.com/ToolingU.WCF.TuAppService/ToolingU.WCF.TuAppService.svc/AuthenticateUser?username=<user>&password=<pw>
Referrer Policy: no-referrer-when-downgrade
Provisional headers are shown
Accept: application/json, text/plain, */*
username: <user>
password: <pw>

这是我在正常运行的模拟器上看到的:

Request URL: http://toolingu.com/ToolingU.WCF.TuAppService/ToolingU.WCF.TuAppService.svc/AuthenticateUser?username=<user>&password=<pw>
Request Method: GET
Status Code: 200 OK
Referrer Policy: no-referrer-when-downgrade
Provisional headers are shown
Accept: application/json, text/plain, */*
username: <user>
password: <pw>

似乎错误立即发生,好像它不是在等待响应返回一样。有什么想法吗?

1 个答案:

答案 0 :(得分:1)

默认情况下,Android Pie(API 29)阻止Http通信(明文流量)。您必须通过在android:usesCleartextTraffic="true"的{​​{1}}标签上添加application来明确启用它