在发送消息(即在Firebase对象上调用setValue)之前,是否有建议的方式来确定用户是联机还是脱机?如何在使用Firebase iOS SDK时检测用户是否在线
例如:
[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进行监控。