启用磁盘持久性(仅限 Android iOS)
要启用磁盘持久性,你应该在应用程序的 FirebaseDatabaseInstance
对象中启用标志 persistenceEnabled
:
Android
FirebaseDatabase.getInstance().setPersistenceEnabled(true);
iOS 版
Database.database().isPersistenceEnabled = true //Swift
[FIRDatabase database].persistenceEnabled = YES; //Objetive-C
如果你想在应用生命周期的某个时刻禁用持久性,你应该记得以相同的方式禁用它:
Android
FirebaseDatabase.getInstance().setPersistenceEnabled(false);
iOS 版
Database.database().isPersistenceEnabled = false //Swift
[FIRDatabase database].persistenceEnabled = NO; //Objetive-C