Skip to content

Commit b65a783

Browse files
author
czu
committed
currentRadioAccessTechnology value for different version of iOS.
1 parent 448902e commit b65a783

File tree

1 file changed

+23
-13
lines changed

1 file changed

+23
-13
lines changed

src/ios/CDVConnection.m

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -60,32 +60,33 @@ - (NSString*)w3cConnectionTypeFor:(CDVReachability*)reachability
6060
} else {
6161
if ([[[UIDevice currentDevice] systemVersion] compare:@"7.0" options:NSNumericSearch] != NSOrderedAscending) {
6262
CTTelephonyNetworkInfo *telephonyInfo = [CTTelephonyNetworkInfo new];
63-
if ([telephonyInfo.currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyGPRS]) {
63+
NSString *currentRadioAccessTechnology = radioAccessNameIn(telephonyInfo)
64+
if ([currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyGPRS]) {
6465
return @"2g";
65-
} else if ([telephonyInfo.currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyEdge]) {
66+
} else if ([currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyEdge]) {
6667
return @"2g";
67-
} else if ([telephonyInfo.currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyWCDMA]) {
68+
} else if ([currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyWCDMA]) {
6869
return @"3g";
69-
} else if ([telephonyInfo.currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyHSDPA]) {
70+
} else if ([currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyHSDPA]) {
7071
return @"3g";
71-
} else if ([telephonyInfo.currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyHSUPA]) {
72+
} else if ([currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyHSUPA]) {
7273
return @"3g";
73-
} else if ([telephonyInfo.currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyCDMA1x]) {
74+
} else if ([currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyCDMA1x]) {
7475
return @"3g";
75-
} else if ([telephonyInfo.currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyCDMAEVDORev0]) {
76+
} else if ([currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyCDMAEVDORev0]) {
7677
return @"3g";
77-
} else if ([telephonyInfo.currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyCDMAEVDORevA]) {
78+
} else if ([currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyCDMAEVDORevA]) {
7879
return @"3g";
79-
} else if ([telephonyInfo.currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyCDMAEVDORevB]) {
80+
} else if ([currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyCDMAEVDORevB]) {
8081
return @"3g";
81-
} else if ([telephonyInfo.currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyeHRPD]) {
82+
} else if ([currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyeHRPD]) {
8283
return @"3g";
83-
} else if ([telephonyInfo.currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyLTE]) {
84+
} else if ([currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyLTE]) {
8485
return @"4g";
8586
} else if (@available(iOS 14.1, *)) {
86-
if ([telephonyInfo.currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyNRNSA]) {
87+
if ([currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyNRNSA]) {
8788
return @"5g";
88-
} else if ([telephonyInfo.currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyNR]) {
89+
} else if ([currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyNR]) {
8990
return @"5g";
9091
}
9192
}
@@ -166,4 +167,13 @@ - (void)pluginInitialize
166167
}
167168
}
168169

170+
static NSString *radioAccessNameIn(CTTelephonyNetworkInfo *networkInfo) {
171+
if (@available(iOS 13.0, *)) {
172+
if (networkInfo.currentRadioAccessTechnology == nil && networkInfo.dataServiceIdentifier) {
173+
return [networkInfo.serviceCurrentRadioAccessTechnology objectForKey:networkInfo.dataServiceIdentifier];
174+
}
175+
}
176+
return networkInfo.currentRadioAccessTechnology;
177+
}
178+
169179
@end

0 commit comments

Comments
 (0)