Ios response with status 0 for url null

I use ionic 3 and I consume an API,
everything ok with android device and chrome browser after installing allow CORS plugin.

But when i build an ios platform, it returns to me : “response with status 0 for url null”

Note that with ionic serve (chrome) in my mac works fine also after installing CORS plugin.

I tryed to install WKWebView, following this post, and this is my plugins :

cordova-plugin-compat 1.2.0 "Compat"
cordova-plugin-device 1.1.4 "Device"
cordova-plugin-ionic-webview 1.1.16 "cordova-plugin-ionic-webview"
cordova-plugin-splashscreen 4.0.3 "Splashscreen"
cordova-plugin-whitelist 1.3.3 "Whitelist"
ionic-plugin-keyboard 2.2.1 “Keyboard”

And also i add this to my config.xml < allow-navigation href=“API_URL” />

My code :

let headers = new Headers();
headers.append(‘Content-Type’, ‘application/x-www-form-urlencoded; charset=UTF-8’ );
headers.append(‘Access-Control-Allow-Origin’,’*’);

let options = new RequestOptions({ headers: headers }); 

this.http.post("API_URL", "data=" + JSON.stringify({.... }), options).subscribe(res => {
    //parse data here
}, error => { console.log(error); }); 

That gives me only on ios devise or emulator : “response with status 0 for url null”

Thaks for help :slight_smile:

Solved

After adding cordova-plugin-ionic-webview,
I Just use native http instead of Http from ‘@angular/http’

And last and step, open platforms > ios > projectname > projectname-Info.plist and change the NSAppTransportSecurity to :

< key>NSAppTransportSecurity< /key>
< dict>
< key>NSAllowsArbitraryLoads< /key>
< true/>
< key>NSExceptionDomains< /key>
< dict>
< key>mydomain.me/< /key>
< dict>
< key>NSIncludesSubdomains< /key>
< true/>
< key>NSThirdPartyExceptionRequiresForwardSecrecy< /key>
< false/>
< /dict>
< /dict>
< /dict>