0

We have an IONIC app where we call to an external service witch publishes a JSON object with data.

When we execute de app through > ionic serve, all works fine on the browser, but when we try to execute it on emulator, nothing happens after the get is executed.

We call it with:

//we pop a message just here, and the device shows it.
  this.http.get('https://ourExternalSite.com/getData').subscribe(data => {
    //do things. We put here a message that never pops
  }, error => {
   //do things, we also put here a message, that never pops neither
  });

We've checked the https://ourExternalSite.com/getData url on the device, and is perfectly reachable and shows the JSON object.

We're not experts on IONIC, this app was developed by a subcontractor and we're trying to integrate it on our environment.

EDIT: I've tried to add a network_security_config.xml file into the project, as those answers propose: Http.get() working but not working in build(Release/Debug) in Ionic 4 Ionic Native HTTP does not work for Anroid 9 (Pie) and up?

But nothing changed

EDIT2: Ok, I narrowed the problem. It has to be with the use of https, if I change the call to a http petition all works fine!

So I supose that I need to somewhat enable the https calls on the network_security_config.xml file

Any help would be much appreciated.

Bardo
  • 2,470
  • 2
  • 24
  • 42
  • https://stackoverflow.com/a/59310320/5909026 – Najam Us Saqib Mar 04 '20 at 14:17
  • Does this answer your question? [Http.get() working but not working in build(Release/Debug) in Ionic 4](https://stackoverflow.com/questions/59306640/http-get-working-but-not-working-in-buildrelease-debug-in-ionic-4) – Najam Us Saqib Mar 04 '20 at 14:18
  • @NajamUsSaqib Sadly no, this not solve the problem – Bardo Mar 05 '20 at 10:59
  • We're using Ionic 3 – Bardo Mar 05 '20 at 11:00
  • Actually, Android changed its HTTP system. I am sure you are having the same issue i answered in my above mentioned post. You can Create `network_security_config.xml` . check this answer: https://stackoverflow.com/a/56801007/5909026 – Najam Us Saqib Mar 05 '20 at 11:49
  • @NajamUsSaqib Nope, sadly this isn't working. I've added the network_security_config.xml file and added it to the resources, but nothing changed – Bardo Mar 05 '20 at 13:55

1 Answers1

0

Ok, finally I fixed the problem mixing the answers proposed by Najam and adding

<trust-anchors>
     <certificates src="@raw/external_site_certificate"/>
</trust-anchors>

to my network_security_config.xml, where external_site_certificate is the public key certificate of the site where I'm trying to make my get call.

Bardo
  • 2,470
  • 2
  • 24
  • 42