Last active
December 14, 2015 18:59
-
-
Save tonycn/5132968 to your computer and use it in GitHub Desktop.
Reachablility to detect 3g or wifi
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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