啟用磁碟永續性(僅限 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