Skip to content

Commit

Permalink
Try to improve reachability status when reachability flags = 0
Browse files Browse the repository at this point in the history
* See tonymillion#65

Signed-off-by: Mark Kirk <[email protected]>
  • Loading branch information
mwkirk committed Jul 10, 2014
1 parent 5350406 commit 7bfd5ab
Showing 1 changed file with 21 additions and 13 deletions.
34 changes: 21 additions & 13 deletions Reachability.m
Original file line number Diff line number Diff line change
Expand Up @@ -310,25 +310,33 @@ -(void)stopNotifier

-(BOOL)isReachableWithFlags:(SCNetworkReachabilityFlags)flags
{
#ifdef DEBUG
NSLog(@"reachability flags = %d -> %@", flags, reachabilityFlags(flags));
#endif
BOOL connectionUP = YES;

if(!(flags & kSCNetworkReachabilityFlagsReachable))
connectionUP = NO;

if( (flags & testcase) == testcase )
connectionUP = NO;

// 7/10/2014, mkirk: In the simulator on Mavericks, often flags = 0 when network is restored.
// Others are seeing this, too: https://github.com/tonymillion/Reachability/issues/65
// Not sure yet if it also happens on device.
if (flags != 0) {
if(!(flags & kSCNetworkReachabilityFlagsReachable))
connectionUP = NO;

if( (flags & testcase) == testcase )
connectionUP = NO;

#if TARGET_OS_IPHONE
if(flags & kSCNetworkReachabilityFlagsIsWWAN)
{
// We're on 3G.
if(!self.reachableOnWWAN)
if(flags & kSCNetworkReachabilityFlagsIsWWAN)
{
// We don't want to connect when on 3G.
connectionUP = NO;
// We're on 3G.
if(!self.reachableOnWWAN)
{
// We don't want to connect when on 3G.
connectionUP = NO;
}
}
}
#endif
}

return connectionUP;
}
Expand Down

0 comments on commit 7bfd5ab

Please sign in to comment.