我的应用程序中有此代码:
-(void)reachAlert:(Reachability*)currentReach {
if(currentReach == hostReach) {
//Make sure we have internet connectivity
//UIAlertView *internetAlert = [[UIAlertView alloc] initWithTitle:@"Excellent" message:@"Host Reached" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"Ok", nil];
//[internetAlert show];
[[SDSyncEngine sharedEngine] startSync];
}
/**
if(currentReach == internetReach) {
//Make sure we have internet connectivity
UIAlertView *internetAlert = [[UIAlertView alloc] initWithTitle:@"Good"
message:@"Internet"
delegate:self
cancelButtonTitle:@"Cancel"
otherButtonTitles:@"Ok", nil];
[internetAlert show];
}
**/
if(currentReach == wifiReach) {
//Make sure we have internet connectivity
UIAlertView *internetAlert = [[UIAlertView alloc] initWithTitle:@"Bad News"
message:@"Only wifi"
delegate:self
cancelButtonTitle:@"Cancel"
otherButtonTitles:@"Ok", nil];
[internetAlert show];
}
[TestFlight passCheckpoint:@"reachAlert"];
}
如您所见,我注释掉了 internetReach,因为我认为,更重要的是我们有 hostReach。因此,默认情况下,我们必须有互联网范围。我还注释掉了 hostReach 警报,只是因为我只想在没有互联网连接的情况下提醒用户。
但是,在 wifi 上测试应用程序时,我只收到 wifi 消息的坏消息。为什么它不给 hostReach 警报?