While getting data from Firebase database with angularfire2 new data is not updated in real time in real device ionic view but works fine in the browser.

I have tried using NgZone but no use. Search the google but no solution.

constructor(
    public ng_zone: NgZone,
    public geolocation: Geolocation,
    public db: AngularFirestore,
  ) {
    this.itemsCollection = db.collection<Item>('locations');
    this.items = this.itemsCollection.snapshotChanges(['added', 'modified']).pipe(
      map(actions => actions.map(a => {
        const data = a.payload.doc.data() as Item;
        const id = a.payload.doc.id;
        console.log(a.payload.doc.data());

        this.ng_zone.run(() => {
          this.lat = a.payload.doc.get('latitude');
          this.lng = a.payload.doc.get('longitude');
        });

        this.docID = id;
        console.log(this.docID + " my id");
        return { id, ...data };
      }))
    );
  }

Problem is only in real device in browser app works fine. In android real device in console I get the results but not in the view. I want to show the updated latitude and longitude in the real device ionic view in real time.

0 Answers