ERROR :
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,
query={
class = inet;
"m_Limit" = "m_LimitAll";
ptcl = htps;
"r_Attributes" = 1;
sdmn = "api.site.com.br";
srvr = "api.site.com.br";
sync = syna;
}
Response in android (OK) return catch :
PROCESS:
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).
VERSION:
package:
"@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"
CODE:
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("https://subdominio.site.com.br/api/login", options)
.map(res => res.json())
.subscribe(data => {
console.error("Subscribe OK -> " + data);
resolve(data);
}, error => {
console.error("Subscribe error ->" + error);
reject(error);
});
});
}
Has anyone ever had this problem? Or do you have any suggestions?