Skip to content

Instantly share code, notes, and snippets.

@tonycn
Last active December 14, 2015 18:59
Show Gist options
  • Save tonycn/5132968 to your computer and use it in GitHub Desktop.
Save tonycn/5132968 to your computer and use it in GitHub Desktop.
Reachablility to detect 3g or wifi
self.internetReachability = [Reachability reachabilityForInternetConnection];
[self.internetReachability startNotifier];
self.wifiReachability = [Reachability reachabilityForLocalWiFi];
[self.wifiReachability startNotifier];
[AppInfo setCurrentNetworkStatus:[self statusByWifiAndInternetReachability]];
- (NetworkStatus)statusByWifiAndInternetReachability {
if (self.wifiReachability.currentReachabilityStatus != NotReachable) {
return ReachableViaWiFi;
} else {
if (self.internetReachability.currentReachabilityStatus == NotReachable) {
return NotReachable;
} else {
return ReachableViaWWAN;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment