在发送消息(即在 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的方法来实现。