0
對數據庫引用有一個onDisconnectRemoveValue
以顯示用戶當前正在「聊天」,並且當用戶離開聊天視圖控制器時我想斷開與FIRDatabase的連接 - 如何觸發此操作斷開功能,而不必完全退出應用程序?在iOS上與Firebase斷開連接
FIRDatabaseReference *connectedRef = [self.dbRef child:@".info/connected"];
[connectedRef observeEventType:FIRDataEventTypeValue withBlock:^(FIRDataSnapshot * _Nonnull snapshot) {
if (snapshot.value) {
NSString *path = [NSString stringWithFormat:@"connections/%@/participants",self.refID];
FIRDatabaseReference *participantsRef = [self.dbRef child:path];
[participantsRef setValue:@{@"avatar":@"avatarURL",@"handle":[self senderDisplayName]} withCompletionBlock:^(NSError * _Nullable error, FIRDatabaseReference * _Nonnull ref) {
[ref onDisconnectRemoveValue];
}];
}
}];
這是JS - 無法在iOS SDK中看到此內容 – Halpo
我提供的鏈接適用於iOS。 –
當我使用goOffline然後再返回在線狀態時,每次重新連接時,'.info/connected'偵聽器會被多次觸發? – Halpo