How to persist Firebase objects to disk in iOS? -
it seems firebase ios implementation doesn't support offline caching of client model. means in practice that:
- for firebase apps requiring authentication, need first authenticate , wait firebase finish login (check user identity, open socket, etc.) before can start moving data. require 1-8 seconds (usually 2-5) depending on network conditions, @ least here in finland.
- after authenticating, firebase first downloads initial set of data , initializes client cache. time perform depends on size of data add listeners for, it's quite fast.
the problem here if you're using firebase implement, example messaging app, you'd want show user cached version of message threads , messages, before actual connection backend server established.
i'd assume correct implementation need handle:
- the client-side model <-> firebase json mapping (i use mantle this)
- persisting client-side model disk (manual implementation using nskeyedarchiver, or core data or such?)
- synchronizing on-disk model firebase-linked model in memory, when connection available (manual implementation?)
has come solution (own or 3rd party) achieve 2) , 3)?
it seems firebase has solved problem since question asked. there lot of resources on offline capabilities firebase, including disk persistence.
for me, turning on persistence simple following in appdelegate:
firebase.defaultconfig().persistenceenabled = true
assuming app has been run internet connection @ least once, should work in loading latest local copy of data.
Comments
Post a Comment