diff --git a/Reachability.h b/Reachability.h index ca943b6..e9a1e0f 100644 --- a/Reachability.h +++ b/Reachability.h @@ -52,6 +52,14 @@ typedef NS_ENUM(NSInteger, NetworkStatus) { ReachableViaWWAN = 1 }; +typedef NS_ENUM(NSUInteger, CellularConnectionType) { + CellularConnectionTypeNone, + CellularConnectionTypeGPRS, + CellularConnectionTypeEdge, + CellularConnectionType3G, + CellularConnectionType4G +}; + @class Reachability; typedef void (^NetworkReachable)(Reachability * reachability); @@ -95,6 +103,7 @@ typedef void (^NetworkReachability)(Reachability * reachability, SCNetworkConnec -(BOOL)isInterventionRequired; -(NetworkStatus)currentReachabilityStatus; +-(CellularConnectionType)currentCellularConnectionType __OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_7_0); -(SCNetworkReachabilityFlags)reachabilityFlags; -(NSString*)currentReachabilityString; -(NSString*)currentReachabilityFlags; diff --git a/Reachability.m b/Reachability.m index 4c1c94a..1eff3f1 100644 --- a/Reachability.m +++ b/Reachability.m @@ -27,6 +27,7 @@ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF #import "Reachability.h" +#import #import #import #import @@ -83,6 +84,26 @@ static void TMReachabilityCallback(SCNetworkReachabilityRef target, SCNetworkRea } } +static CellularConnectionType cellularConnectionType(NSString *type) { + if (!type) { + return CellularConnectionTypeNone; + } + + return [@{ + CTRadioAccessTechnologyGPRS : @(CellularConnectionTypeGPRS), + CTRadioAccessTechnologyEdge : @(CellularConnectionTypeEdge), + CTRadioAccessTechnologyWCDMA : @(CellularConnectionType3G), + CTRadioAccessTechnologyHSDPA : @(CellularConnectionType3G), + CTRadioAccessTechnologyHSUPA : @(CellularConnectionType3G), + CTRadioAccessTechnologyCDMA1x : @(CellularConnectionTypeEdge), + CTRadioAccessTechnologyCDMAEVDORev0 : @(CellularConnectionType3G), + CTRadioAccessTechnologyCDMAEVDORevA : @(CellularConnectionType3G), + CTRadioAccessTechnologyCDMAEVDORevB : @(CellularConnectionType3G), + CTRadioAccessTechnologyeHRPD : @(CellularConnectionType3G), + CTRadioAccessTechnologyLTE : @(CellularConnectionType4G), + }[type] integerValue]; +} + @implementation Reachability @@ -432,6 +453,12 @@ -(NSString*)currentReachabilityFlags return reachabilityFlags([self reachabilityFlags]); } +#pragma mark - Cellular connection type + +-(CellularConnectionType)currentCellularConnectionType { + return cellularConnectionType([CTTelephonyNetworkInfo new].currentRadioAccessTechnology); +} + #pragma mark - Callback function calls this method -(void)reachabilityChanged:(SCNetworkReachabilityFlags)flags diff --git a/Reachability.podspec b/Reachability.podspec index 5c6a12e..c104fd1 100644 --- a/Reachability.podspec +++ b/Reachability.podspec @@ -13,7 +13,7 @@ EOF Pod::Spec.new do |s| s.name = 'Reachability' - s.version = '3.2' + s.version = '3.3' s.summary = 'ARC and GCD Compatible Reachability Class for iOS and OS X. Drop in replacement for Apple Reachability.' s.homepage = 'https://github.com/tonymillion/Reachability'