【发布时间】:2014-05-23 10:04:59
【问题描述】:
在发送消息(即在 Firebase 对象上调用 setValue)之前,是否有推荐的方法来确定用户是在线还是离线?
例如:
[firebase setValue:someValue withCompletionBlock:^(NSError *error, Firebase *ref) {
// This block is ONLY executed if the write actually completes. But what if the user was offline when this was attempted?
// It would be nicer if the block is *always* executed, and error tells us if the write failed due to network issues.
}];
我们需要在我们的 iOS 应用程序中使用它,因为如果用户进入隧道,他们可能会失去连接。如果 Firebase 不提供内置方法来执行此操作,我们将仅求助于监控 iOS 的 Reachability API。
【问题讨论】: