title: Ionic 3 Response with status: 0 for URL: null
body: <p>I have an Ionic 3 app. I recently added the iOS platform.</p>
  
  <p>When i run it on iOS (emulator and device) all the server requests that has headers fail with the error <strong>"Response with status: 0  for URL: null"</strong>. On Android those requests works fine.</p>
  
  <p>If I do the requests <strong>without headers</strong> i get the expected response from server.</p>
  
  <p>I know the problem is with <strong>WKWebView</strong> and <strong>CORS</strong>. The server has the CORS configured correctly. I do the requests with <strong>@angular/http</strong> module.</p>
  
  <p>Let's see some code.</p>
  
  <p>This is my provider for doing requests to server: </p>
  
  <pre><code>import { Injectable } from '@angular/core';
  import { Content } from 'ionic-angular';
  import { Http, Headers, RequestOptions, URLSearchParams } from '@angular/http';
  import { HTTP } from '@ionic-native/http';
  import { Observable } from 'rxjs/Observable';
  import 'rxjs/add/operator/map';
  import { Globalization } from '@ionic-native/globalization';
  
  import { Globals } from '../providers/globals';
  
  ...
  
  /// Here we have one example Request (it's inside a method)
  
  /// Here I create the URL for the request
  let url = this.server_url + this.server_functions.doSearch;
  
  /// Now I create the Headers for the Request
  let headers = new Headers();
  /// As You can see, I have tried to pass diferent headers to server
      // headers.append("Access-Control-Allow-Origin","*");
      // headers.append("Origin", "https://localhost:8080");
      // headers.append("Access-Control-Allow-Methods","POST, GET, OPTIONS, PUT");
      // headers.append("Accept","application/json");
      // headers.append("Content-Type","application/json; charset=utf-8");
  
  /// If the user is logged in I have to send this headers to server
  if ( !this.globals.guestMode ) {
      headers.append("TokenAuth", this.globals.getLogRegData()["TokenAuth"]);
      headers.append("IdAuth", this.globals.getLogRegData()["IdAuth"]);
  }
  
  /// And here we start the GET Request
  this.http.get( url, { headers: headers } ).map(res =&gt; res.json()).subscribe(
      data =&gt; {
          // console.log( JSON.stringify(data) );
          callback( data );
      },
      err =&gt; {
          console.log("ELOL: "+err);
      }
  );
  </code></pre>
  
  <p>By the other way, I decided to try the @ionic-native/http module (as you can see in the imports) to avoid the WKWebView and CORS problems, but when I do the request with it, I got this error:</p>
  
  <pre><code>WARN: Native: tried calling HTTP.get, but the HTTP plugin is not installed.
  WARN: Install the HTTP plugin: 'ionic cordova plugin add cordova-plugin-advanced-http'
  </code></pre>
  
  <p>This is how I do the Request with the native plugin:</p>
  
  <pre><code>this.httpnative.get(url, {}, {})
      .then(data =&gt; {
  
          console.log(data.status);
          console.log(data.data); // data received by server
          console.log(data.headers);
  
      })
      .catch(error =&gt; {
  
          console.log(error.status);
          console.log(error.error); // error message as string
          console.log(error.headers);
  
      });
  </code></pre>
  
  <p>This is a fragment of my app.module.ts:</p>
  
  <pre><code>import { HttpModule } from '@angular/http';
  import { HTTP } from '@ionic-native/http';
  ...
  @NgModule({
  ...
   imports: [
  ...
      HttpModule,
      HTTP,
  ...
  
    ],
  })
  </code></pre>
  
  <p>I hope some one can bring me some light on this, because I'm so lost in the paths of Ionic.</p>
  
  <p>Thank You.</p>