Make data persistent (Firebase/AngularFire2)

Hi,

I developed an app with ionic 2, using Firebase through AngularFire2.

I have an issue with the offline behavior. When I am offline, I can log into my app (which is just fine), but I don’t have any data retrieved from local storage…
Other example, if I log into my app, force closing, then restart, I am still logged in but all data has disappeared.

Is there any setting to change for forcing persistence ? I saw the “.enablePersistence()” setting for Firestore, but I can’t find anything similar for Firebase…

Thanks vm !

No clue ? :confused:

If you need offline support, I suggest you use Firestore. The Firebase Realtime Database does not support offline support out of the box. There is angularfire2-offline, however it only supports angularfire2 v4 and the author himself recommends switching to Firestore (see here).

Ok thanks, I am trying to migrate to Firestore and see what happens then !

Did you manage to make it work using FIrestore? i’m having a problem . when i remove the.enablePersistence() it works fine but when i add enablePersistence() in my ionic it doesn’t work

Yep with Firestore it works like a charm :slight_smile: To activate Persistence, in app.module.ts :

imports: [
       ...
    AngularFireModule.initializeApp(firebaseConfig),
    AngularFireAuthModule,
    AngularFirestoreModule.enablePersistence()
    
    ],
1 Like

i already did that but i said when using with
enablePersistence()[firestore] my app doest not load any data from my
firestore database . i think i’ll try it first with other device btw thank
for your reply

I realize this was more than a year ago, but did you make any headway on this? Right now I’m seeing an issue where if I use enablePersistence then the app will only occasionally get new data from Firestore. Most of the time it uses cached data