Repository: cordova-plugin-network-information
Updated Branches:
  refs/heads/master d018f7ead -> 3968f2069


Adding CT radio information

Project: 
http://git-wip-us.apache.org/repos/asf/cordova-plugin-network-information/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/cordova-plugin-network-information/commit/791d828f
Tree: 
http://git-wip-us.apache.org/repos/asf/cordova-plugin-network-information/tree/791d828f
Diff: 
http://git-wip-us.apache.org/repos/asf/cordova-plugin-network-information/diff/791d828f

Branch: refs/heads/master
Commit: 791d828fd4a66feb143cf1b71a99cbcb2c132294
Parents: d018f7e
Author: edparsons <[email protected]>
Authored: Mon Dec 28 09:20:21 2015 +0000
Committer: edparsons <[email protected]>
Committed: Mon Dec 28 09:20:21 2015 +0000

----------------------------------------------------------------------
 src/ios/CDVConnection.m | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-network-information/blob/791d828f/src/ios/CDVConnection.m
----------------------------------------------------------------------
diff --git a/src/ios/CDVConnection.m b/src/ios/CDVConnection.m
index 223dd7c..2bcaa66 100644
--- a/src/ios/CDVConnection.m
+++ b/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,30 @@
             if (isConnectionRequired) {
                 return @"none";
             } else {
+                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,6 +143,8 @@
     [self.internetReach startNotifier];
     [[NSNotificationCenter defaultCenter] addObserver:self 
selector:@selector(updateConnectionType:)
                                                  
name:kReachabilityChangedNotification object:nil];
+    [[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];


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to