Ionic 4 Http failure response on ios

I have built a woocommerce marketplace app. everything works fine on browser and android. But on ios i get an unknown error response from http. Please, how do i go about it. here’s the error below.

2019-04-07 16:56:40.714562+0100 Melanoid Exchange[51005:583684] ERROR: {"headers":{"normalizedNames":{},"lazyUpdate":null,"headers":{}},"status":0,"statusText":"Unknown Error","url":"https://melanoidexchange.com/wp-json/wc/v3/products?consumer_key=ck_0f98c08be0f4755f8acfff2dd2e053f777ebb237&consumer_secret=cs_ad4fc0e40c4de6d9d10c58f2b158427af1284d7d&page=1&status=publish","ok":false,"name":"HttpErrorResponse","message":"Http failure response for https://melanoidexchange.com/wp-json/wc/v3/products?consumer_key=ck_0f98c08be0f4755f8acfff2dd2e053f777ebb237&consumer_secret=cs_ad4fc0e40c4de6d9d10c58f2b158427af1284d7d&page=1&status=publish: 0 Unknown Error","error":{"isTrusted":true}}
2 Likes

I am having a similar issue. Most of the cases that I found are having fail response from unknown URL, but for my case, I am getting fail response from a known URL like yours.

Using Laravel as backend, and have added the headers to allow CORS.

Still researching…

I am facing the same issue with known url on both iOS(Xcode Build) and Android(Android Studio Build).
If you got any solution please share with us.

NOTE: I am getting this only on POST request. GET works fine for me

iOS :
[error] - ERROR {“headers”:{“normalizedNames”:{},“lazyUpdate”:null,“headers”:{}},“status”:0,“statusText”:“Unknown Error”,“url”:“https://www.myurl.com/sendfeed.php/",“ok”:false,“name”:“HttpErrorResponse”,“message”:"Http failure response for https://www.myurl.com/sendfeed.php/: 0 Unknown Error”,“error”:{“isTrusted”:true}}

Android:
E/Capacitor/Plugin/Console: ERROR {“headers”:{“normalizedNames”:{},“lazyUpdate”:null,“headers”:{}},“status”:0,“statusText”:“Unknown Error”,“url”:“https://www.myurl.com/sendfeed.php/",“ok”:false,“name”:“HttpErrorResponse”,“message”:"Http failure response for https://www.myurl.com/sendfeed.php/: 0 Unknown Error”,“error”:{“isTrusted”:true}

Please were you able to find a solution…i’m having this same error on ios

Instead of using HttpClient from ‘@angular/common/http’, I used the ionic-native HTTP plugin.
HTTP from ‘@ionic-native/http/ngx’
That solved my problem.
Please go through this link to implement it https://ionicframework.com/docs/native/http

I managed to solve mine by

Remove and Add VebView Plugin V 2.3.2

cordova plugin rm cordova-plugin-ionic-webview

cordova plugin add cordova-plugin-ionic-webview@2.3.2

1 Like

Same problem for me
the solution was:
ionic cordova remove platform android
ionic cordova add platform android

This error happens in ios. The problem is that you don’t have permissions to access to the url reference, you can try to add the rights “allow” tags on the config.xml but didn’t work for me.

The solution is to not use a URL that reference to the file system or a blob. For example you can transform the blob or the svg or whatever image format you have to base64 url like:

  renderPictureAsBase64(image) {
    return 'data:image/svg+xml;base64,' + btoa(unescape(encodeURIComponent(image)))
  }

then you can do

img.src = this.renderPictureAsBase64url);

(In my case the “image” was a svg tag like <svg …>, but you can take an image and parse it to base64 and will work, just take care or add the proper mimetype like “data:image/svg+xml;base64,” for svg.)