Firestore Offline Persistence does not sync in Ionic

Viewed 153

I am using Firestore with Ionic. I have used the offline persistence, as below (I have added all of the firestore modules that I am using)

    AngularFireModule.initializeApp(environment.firebase),
    AngularFirestoreModule.enablePersistence(),
    AngularFireStorageModule,
    AngularFireMessagingModule,

However I find that I am having stale data on my mobile. Updates using another mobile to the firestore collection does not reflect on my mobile. If I remove offline persistence, then it is reflecting accurately.

So I added a refresh option as below:

this.firestore.collection(col, ref => ref.orderBy('modifiedAt', 'desc').limit(1)).get({ source: 'server' }).subscribe(doc => alert(doc['name']));

When I refresh, I get the last modified document from the server. But when I check my list, I still find stale data. Anyone has faced this problem?

Versions:

    "@angular/common": "~11.0.5",
    "@angular/core": "~11.0.5",
    "@angular/fire": "^6.1.4",
    "@ionic/angular": "^5.5.2",
    "firebase": "^8.0.0",

Any help is highly appreciated.

0 Answers
Related