iOS : Objective-C : Firebase : Is it possible to r

2020-04-26 23:46发布

问题:

@Description:

I have data already exists at some endpoint(friends_list) so this is my reference :

https://xxxxxx.firebaseio.com/friends_list

Now, I have enabled disk persistence i.e., i am allowed to cache the data as well as using the below code:

 [FIRDatabase database].persistenceEnabled = YES;

Now, I have loaded the application and I have cached the data to disk by using the following code:

 FIRDatabaseReference *globalRef = [[FIRDatabase database] reference];

 FIRDatabaseReference *ref = [globalRef child:@"friends_list"];
 [ref keepSynced:YES];

//here comes : other stuff for listeners (ChildAdded, ChildChanged, ChildRemoved)

I am able to cache the data, my question is when there is no internet I have to read the data from disk first and display them in my UI.

This is happening but there is a delay. Can some one help me on this.

Thanks.