Ionic call rest service no catch http response code 401 on IOS

I’m having trouble in calling the rest service by IOS, since in android everything works fine. When I make the call passing a login and password invalid, the server returns status 401 (via postman / android / ionic serves), now when I do it via IOS it does not return anything when call is made (I put a log on the server it identifies and shows that returned) it does not receive anything like return in subscribe nor in catch of http.get, with that I can not catch the error and make the treatment.

Summarizing the call of the APi is made by IOS but when the error in the subscribe does not fall in catch when it returns 401. However when I am without internet it falls in the catch sound status 0.

Response in IOS (FAIL) not return catch:

Error print on console xCode:

CredStore - performQuery - Error copying matching creds.  Error=-25300, 
    class = inet;
    "m_Limit" = "m_LimitAll";
    ptcl = htps;
    "r_Attributes" = 1;
    sdmn = "";
    srvr = "";
    sync = syna;

Response in android (OK) return catch :

I am making a call to an api in rest, as the type GET and passing as parameter the login and password in the base64 Authorization.
When I make the process to send the correct login and password, it is returning status 200 with a valid token. But when an invalid login and password is sent the server returns status 401 (this is ok, I did the postman tests).


"@angular/common": "4.1.2",
        "@angular/compiler": "4.1.2",
        "@angular/compiler-cli": "4.1.2",
        "@angular/core": "4.1.2",
        "@angular/forms": "4.1.2",
        "@angular/http": "4.1.2",
        "@angular/platform-browser": "4.1.2",
        "@angular/platform-browser-dynamic": "4.1.2",
        "@ionic-native/core": "3.7.0",
        "@ionic-native/in-app-browser": "^3.10.3",
        "@ionic-native/onesignal": "^4.3.0",
        "@ionic-native/splash-screen": "3.7.0",
        "@ionic-native/status-bar": "3.7.0",
        "@ionic/storage": "2.0.1",
        "cordova-android": "^6.2.3",
        "cordova-ios": "^4.4.0",
        "cordova-plugin-console": "^1.0.7",
        "cordova-plugin-device": "^1.1.6",
        "cordova-plugin-inappbrowser": "^1.7.1",
        "cordova-plugin-splashscreen": "^4.0.3",
        "cordova-plugin-statusbar": "^2.2.3",
        "cordova-plugin-whitelist": "^1.3.2",
        "ionic-angular": "3.3.0",
        "ionic-plugin-keyboard": "^2.2.1",
        "ionicons": "3.0.0",
        "onesignal-cordova-plugin": "^2.2.1",
        "rxjs": "5.1.1",
        "sw-toolbox": "3.6.0",
        "zone.js": "0.8.10"


  getToken(login, senha): Promise<{}> {
    return new Promise((resolve, reject) => {
      let options = new RequestOptions({
        headers: new Headers({
          'Authorization': 'Basic ' + btoa(login + ":" + senha),
          "cache-control": "no-cache"
      this.http.get("", options)
        .map(res => res.json())
        .subscribe(data => {
          console.error("Subscribe OK -> " + data);
        }, error => {
          console.error("Subscribe error ->" + error);

Has anyone ever had this problem? Or do you have any suggestions?


Maybe I’m wrong, but it seems this issue appears since iOS 11. I’m encountering same issue here. Not yet understood neither why nor how to solve it.
I’ll let you know in this case.

Anybody has tried to correct this error ?

Hi, so the problem has been solved, I had to add the following plugin and with it make the “useBasicAuth” flame.

My problem I had was the following, there is a bug in the iOS cord that exists long ago in no one else solves it.

This occurs because I’m making a call to a basic type authentication service, and in the headers of the service it returns < WWW-Authenticate: Basic realm = “Access to the staging site” -> it opens the dialog in the browser. But in the IOS error.
Take a test without this guy in the headers or add plugin

Hi, so the problem has been solved.

Look in post.

This plugin is not available for Ionic 1, but we can use the Cordova plugin directly ( [the same used by Ionic 2 HTTP plugin]).
In my case, I just had call “cordova.plugin.http.get” instead of “$http.get” in the auth function (no other changes needed).