0

I have a strange issue with Ionic mobile application only on the Android version. I have several HTTP requests that I call external APIs and get some data. While I am on Ionic Serve, Ionic Lab or iOS mobile app, I don't have any issue. However, on the Android version, it doesn't update the data of the HTTP requests, but only after 2-3 days.

If I uninstall the app and install it again, it gets the latest data.

This is the HTML:

<ion-item [ngClass]="{'hidden' : (item['status'] == 'trash')}" 
          item-bcg 
          *ngFor="let item of cars; let i = index;" 
          (click)="onClick($event, item)">
...do my stuff...
</ion-item>

This is my component:

getCars() {
    return this.wpApi.getCars(this.category, this.maxResults)
      .subscribe( (res) => {
        this.cars = res['entries']; 
        this.labels = res['_labels']; 
      })
 }

And this is my service:

  getCars = function (category, maxResults) {    
    let url = this.domain + "/wp-json/gf/v2/forms/1/entries?_labels=1&paging[page_size]=" + maxResults;      
    let headers: Headers = new Headers();
    headers.append("Authorization", "Basic " + this.bt);
    headers.append("Content-type", "application/json");
    return this.http.get(url, {
        headers: headers
      })
      .map(response => response.json())   
  };

I call the getCars() every time the view is opened and also I have a pull to refresh feature that manually calls it when you pull the screen from top to bottom.

This doesn't happen anywhere else. Just on the published Android app on the market.

"@angular/common": "4.1.3",

"@ionic-native/core": "3.12.1"

Dinal Koyani
  • 455
  • 3
  • 6
Tasos
  • 7,325
  • 18
  • 83
  • 176
  • are you storing any of the data in localstorage? – Prithivi Raj Nov 01 '17 at 12:12
  • @PrithiviRaj Nothing related with this part of the API – Tasos Nov 01 '17 at 12:18
  • Does the issue just happen on the published version in the store or also on android devices when you do a local build? – David Nov 01 '17 at 12:39
  • @David I don't think that I have tried it. For debugging, I use Ionic View. Where I upload the app and through the Ionic View mobile application, I load the app on the mobile. It works ok there. – Tasos Nov 01 '17 at 12:58
  • Thats actually a very bad idea. Ionic View is not for debugging its for beta distribution. You should **always** run your app on a real device or at least in the simulator for debugging. You can use chrome dev tools to check for errors on the console and in your case you should especially check the network tab in chrome dev tools. – David Nov 01 '17 at 13:06
  • I do this with the Ionic Lab which supposed to simulate the mobile platforms. There I check the chrome dev tools and there isn't any error and the API returns the latest dataset on the network. – Tasos Nov 01 '17 at 13:08

0 Answers0