Beth Mezias
Beth Mezias

Reputation: 270

Export data to preload into a Firebase instance in a mobile app

The use case is a dual platform mobile app for an event. There is a schedule with photos, links, bios of the speakers and talk descriptions. If all of the attendees happen to download and open the app at the same time and in the same place, they might not get the best experience -> the WiFi might slow the calls into the data server, calls into the FireBase server side will spike.

Is it possible to export a database from the server side and preload the event schedule data into the mobile app download? Upon launch the app can sync any last minute updates, as needed, with a connection and a short sync to Firebase.

If this type of architecture is not available, is there an alternative that the Firebase team would recommend?

Upvotes: 1

Views: 681

Answers (2)

dazza5000
dazza5000

Reputation: 7628

On android you can ship a sql database in the assets directory with the app and then reconcile it with the updates when the users open the app. The Firebase database is a json file. You could also ship that in the assets directory and then reconcile on first load.

Upvotes: 0

Frank van Puffelen
Frank van Puffelen

Reputation: 599766

There is no way within the Firebase Database API to preload data into the disk cache.

Two things I can think of (neither of them very nice):

  1. Have the client read the JSON file from your app's resources and write it to the location. The end result of this will be that the data on the server stays unmodified. But it does result in each client writing the same data to the server, so the inverse of your original problem (and likely worse performing).
  2. Have a wrapper around the Firebase API calls that loads from the JSON file and then have them later attach listeners after a random delay (to reduce the rush on the app).

As said, neither of them is very good. For both of them, you can download the JSON from the Firebase Database console.

In my experience the usage of conference apps is a lot lower than most developers/organizers imagine. It's also typically quite well spread out over the duration of the conference. So reducing the amount of data you load might be enough to make things work.

Upvotes: 2

Related Questions