My app needs to load json data, and this works in browser (ionic serve), and in my Android app (apk), but the json won't load in my IOS app (ipa).
I am building the app with Ionic Pro, here are relevent version numbers: | macOS version | 10.13.2 | | Xcode version | Xcode 9.2 | | | Build version 9C40b | | Node.js version | v8.11.1 | | Cordova CLI version | 7.1.0 | | npm version | 5.6.0
Currently, my client is pushing a .json file to his web server, and I am reading it from there. This is the process we would prefer to continue using, however I have also tried loading json stored locally in the app, and fetching json from firebase (see 2 commented-out lines in code). All 3 methods work in browser/Android, and fail in IOS.
This is the code in my provider that is supposed to load the json (only the relevant parts, full code in public repo https://github.com/marvabban/antitour):
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { Storage } from '@ionic/storage';
import { Observable } from 'rxjs/Observable';
@Injectable()
export class DataProvider {
data: any;
sitePrefix: string = "http://xxxxxx.com/app-data/";
//sitePrefix: string = "https://xxxx.firebaseapp.com/";
//sitePrefix: string = "assets/";
cities: Array<any> = []
currentCityID: number = -1;
currentCity: any = {};
currentStory: number = 0;
constructor(public http: HttpClient, public storage:Storage) {
this.load();
}
load() {
let data:Observable<any> = this.http.get(this.sitePrefix+'data/data5.json');
data.subscribe(result => {
this.data = result;
this.storage.set('localdata', JSON.stringify(this.data));
});
}
}