diff options
| author | Jules Laplace <jules@okfoc.us> | 2016-11-08 12:37:03 -0500 |
|---|---|---|
| committer | Jules Laplace <jules@okfoc.us> | 2016-11-08 12:37:03 -0500 |
| commit | ef4f212fc1482136dba1e690ec589b315b4a377f (patch) | |
| tree | 0b7e16d72567fafcfd3e08d7c5c591ad07a63458 /StoneIsland/plugins/cordova-plugin-network-information/src/ios | |
| parent | 5fa81da81260d65113f57a293b6256d334fe8e2d (diff) | |
build 0.7.0
Diffstat (limited to 'StoneIsland/plugins/cordova-plugin-network-information/src/ios')
| -rw-r--r--[-rwxr-xr-x] | StoneIsland/plugins/cordova-plugin-network-information/src/ios/CDVConnection.h | 0 | ||||
| -rw-r--r--[-rwxr-xr-x] | StoneIsland/plugins/cordova-plugin-network-information/src/ios/CDVConnection.m | 31 | ||||
| -rw-r--r--[-rwxr-xr-x] | StoneIsland/plugins/cordova-plugin-network-information/src/ios/CDVReachability.h | 0 | ||||
| -rw-r--r--[-rwxr-xr-x] | StoneIsland/plugins/cordova-plugin-network-information/src/ios/CDVReachability.m | 6 |
4 files changed, 36 insertions, 1 deletions
diff --git a/StoneIsland/plugins/cordova-plugin-network-information/src/ios/CDVConnection.h b/StoneIsland/plugins/cordova-plugin-network-information/src/ios/CDVConnection.h index 8add0279..8add0279 100755..100644 --- a/StoneIsland/plugins/cordova-plugin-network-information/src/ios/CDVConnection.h +++ b/StoneIsland/plugins/cordova-plugin-network-information/src/ios/CDVConnection.h diff --git a/StoneIsland/plugins/cordova-plugin-network-information/src/ios/CDVConnection.m b/StoneIsland/plugins/cordova-plugin-network-information/src/ios/CDVConnection.m index 37497675..6715322a 100755..100644 --- a/StoneIsland/plugins/cordova-plugin-network-information/src/ios/CDVConnection.m +++ b/StoneIsland/plugins/cordova-plugin-network-information/src/ios/CDVConnection.m @@ -16,6 +16,7 @@ specific language governing permissions and limitations under the License. */ +#import <CoreTelephony/CTTelephonyNetworkInfo.h> #import "CDVConnection.h" #import "CDVReachability.h" @@ -57,6 +58,32 @@ if (isConnectionRequired) { return @"none"; } else { + if ([[[UIDevice currentDevice] systemVersion] compare:@"7.0" options:NSNumericSearch] != NSOrderedAscending) { + CTTelephonyNetworkInfo *telephonyInfo = [CTTelephonyNetworkInfo new]; + if ([telephonyInfo.currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyGPRS]) { + return @"2g"; + } else if ([telephonyInfo.currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyEdge]) { + return @"2g"; + } else if ([telephonyInfo.currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyWCDMA]) { + return @"3g"; + } else if ([telephonyInfo.currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyHSDPA]) { + return @"3g"; + } else if ([telephonyInfo.currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyHSUPA]) { + return @"3g"; + } else if ([telephonyInfo.currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyCDMA1x]) { + return @"3g"; + } else if ([telephonyInfo.currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyCDMAEVDORev0]) { + return @"3g"; + } else if ([telephonyInfo.currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyCDMAEVDORevA]) { + return @"3g"; + } else if ([telephonyInfo.currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyCDMAEVDORevB]) { + return @"3g"; + } else if ([telephonyInfo.currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyeHRPD]) { + return @"3g"; + } else if ([telephonyInfo.currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyLTE]) { + return @"4g"; + } + } return @"cellular"; } } @@ -118,7 +145,9 @@ [self.internetReach startNotifier]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updateConnectionType:) name:kReachabilityChangedNotification object:nil]; - if (&UIApplicationDidEnterBackgroundNotification && &UIApplicationWillEnterForegroundNotification) { + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updateConnectionType:) + name:CTRadioAccessTechnologyDidChangeNotification object:nil]; + if (UIApplicationDidEnterBackgroundNotification && UIApplicationWillEnterForegroundNotification) { [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onPause) name:UIApplicationDidEnterBackgroundNotification object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onResume) name:UIApplicationWillEnterForegroundNotification object:nil]; } diff --git a/StoneIsland/plugins/cordova-plugin-network-information/src/ios/CDVReachability.h b/StoneIsland/plugins/cordova-plugin-network-information/src/ios/CDVReachability.h index 01a95c35..01a95c35 100755..100644 --- a/StoneIsland/plugins/cordova-plugin-network-information/src/ios/CDVReachability.h +++ b/StoneIsland/plugins/cordova-plugin-network-information/src/ios/CDVReachability.h diff --git a/StoneIsland/plugins/cordova-plugin-network-information/src/ios/CDVReachability.m b/StoneIsland/plugins/cordova-plugin-network-information/src/ios/CDVReachability.m index c60261ae..1399867e 100755..100644 --- a/StoneIsland/plugins/cordova-plugin-network-information/src/ios/CDVReachability.m +++ b/StoneIsland/plugins/cordova-plugin-network-information/src/ios/CDVReachability.m @@ -142,6 +142,9 @@ static void CDVReachabilityCallback(SCNetworkReachabilityRef target, SCNetworkRe retVal->reachabilityRef = reachability; retVal->localWiFiRef = NO; } + else { + CFRelease(reachability); + } } return retVal; } @@ -156,6 +159,9 @@ static void CDVReachabilityCallback(SCNetworkReachabilityRef target, SCNetworkRe retVal->reachabilityRef = reachability; retVal->localWiFiRef = NO; } + else { + CFRelease(reachability); + } } return retVal; } |
