3

I build apps that bundle up JSON data. I want to switch to Firebase as my backend, but I need to ensure I can access the data even if firebase is offline. There's no guarantee that the user will have an internet connection at the time they launch the app. The data consists of a fairly large JSON blob.

I heard that firebase does cache data on iOS for offline access, and that's great. I just need to know how to bundle the data for that first time the app is ran, so the user can use the app prior to getting to a network connection.

igorsales
  • 612
  • 6
  • 8
  • I know it's a long time ago but did you find a solution to this? – James May 20 '16 at 10:22
  • I haven't checked lately, but they had promised this a while back, so I would expect it to be there. However, if you're writing here, it probably means it isn't available yet. – igorsales May 22 '16 at 03:29

1 Answers1

4

As it sounds like you discovered, the Firebase Obj-C client does have beta support for offline access / disk persistence. Details can be found here.

But that doesn't address your desire to "seed" the app with initial data so that it has data available before the app has ever been able to connect to Firebase. Unfortunately, there's no direct support for that.

One hacky solution you could attempt with Firebase is to just do a setValue with the data in question, in order to seed the cache. This should work but will eventually try to write that data to Firebase, when the app gets connected, so you'd probably want to have security rules to prevent the user from actually modifying that data. As I said, it'd be a hacky solution.

For now it might be best to just handle this with special logic in your app that pulls data from some other data source (hardcoded values or an embedded file or whatever) until the first time you get data from Firebase.

Sorry there's no direct support for this at the moment. We'll take a look to see if we could support this more directly in the future.

Michael Lehenbauer
  • 16,229
  • 1
  • 57
  • 59
  • Any News on this? see also this post: https://stackoverflow.com/questions/39602673/firebase-offline-storage-advanced-manual-sync-and-progress-information?noredirect=1&lq=1 If Firebase could support this, it'd be a great solution for our App, currently we're syncing with a sqlite DB & redowloading all Contents at App start – brokedid Sep 13 '17 at 11:12