Search code examples
angularionic2angularfire2-offline

Angular2Offline does not sync data if ionic app is closed without ever connecting to internet


I used Angular2Offline to sync my ionic app data and provide 'Offline First' capabilities to my app.

Tutorial for implementation of Angular2Offline at JaveBratt

The data is synced fine, App Start in Offline mode retrieves data from local store, any changes made on Firebase while the app was Offline are synced on connection restore and any changes at app are also synced to Firebase database.

Issue: is that if an app starts in offline mode, and remain in offline mode until it is closed, without going online, if there are changes made or new items added during this period, these changes will disappear until time app is back online.

However, once the app is online, the changes/additions would re-appear both in the app and in Firebase database.

Question: Could we actually interact at app start event in order to show the items added in previous Offline mode? I tried to access local storage at platform.ready() in app.component.ts but with no success, do we need to make changes to Angular2Offline library?

Any help would be appreciated.


Solution

  • Issue now fixed

    This should be fixed in AngularFire2 Offline version 4.2.2

    Demo

    You can test it in the demo using the following steps:

    1. Visit: https://angularfire2-offline.firebaseapp.com/write-list
    2. Go offline
    3. Refresh while offline
    4. Add "Apples" to list
    5. Refresh

    If you still see "Apples" after refreshing, then the issue should be fixed.