Skip to content

Commit

Permalink
currentRadioAccessTechnology value for different version of iOS.
Browse files Browse the repository at this point in the history
  • Loading branch information
czu committed Jun 16, 2022
1 parent 448902e commit b65a783
Showing 1 changed file with 23 additions and 13 deletions.
36 changes: 23 additions & 13 deletions src/ios/CDVConnection.m
Original file line number Diff line number Diff line change
Expand Up @@ -60,32 +60,33 @@ - (NSString*)w3cConnectionTypeFor:(CDVReachability*)reachability
} else {
if ([[[UIDevice currentDevice] systemVersion] compare:@"7.0" options:NSNumericSearch] != NSOrderedAscending) {
CTTelephonyNetworkInfo *telephonyInfo = [CTTelephonyNetworkInfo new];
if ([telephonyInfo.currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyGPRS]) {
NSString *currentRadioAccessTechnology = radioAccessNameIn(telephonyInfo)
if ([currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyGPRS]) {
return @"2g";
} else if ([telephonyInfo.currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyEdge]) {
} else if ([currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyEdge]) {
return @"2g";
} else if ([telephonyInfo.currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyWCDMA]) {
} else if ([currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyWCDMA]) {
return @"3g";
} else if ([telephonyInfo.currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyHSDPA]) {
} else if ([currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyHSDPA]) {
return @"3g";
} else if ([telephonyInfo.currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyHSUPA]) {
} else if ([currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyHSUPA]) {
return @"3g";
} else if ([telephonyInfo.currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyCDMA1x]) {
} else if ([currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyCDMA1x]) {
return @"3g";
} else if ([telephonyInfo.currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyCDMAEVDORev0]) {
} else if ([currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyCDMAEVDORev0]) {
return @"3g";
} else if ([telephonyInfo.currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyCDMAEVDORevA]) {
} else if ([currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyCDMAEVDORevA]) {
return @"3g";
} else if ([telephonyInfo.currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyCDMAEVDORevB]) {
} else if ([currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyCDMAEVDORevB]) {
return @"3g";
} else if ([telephonyInfo.currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyeHRPD]) {
} else if ([currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyeHRPD]) {
return @"3g";
} else if ([telephonyInfo.currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyLTE]) {
} else if ([currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyLTE]) {
return @"4g";
} else if (@available(iOS 14.1, *)) {
if ([telephonyInfo.currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyNRNSA]) {
if ([currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyNRNSA]) {
return @"5g";
} else if ([telephonyInfo.currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyNR]) {
} else if ([currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyNR]) {
return @"5g";
}
}
Expand Down Expand Up @@ -166,4 +167,13 @@ - (void)pluginInitialize
}
}

static NSString *radioAccessNameIn(CTTelephonyNetworkInfo *networkInfo) {
if (@available(iOS 13.0, *)) {
if (networkInfo.currentRadioAccessTechnology == nil && networkInfo.dataServiceIdentifier) {
return [networkInfo.serviceCurrentRadioAccessTechnology objectForKey:networkInfo.dataServiceIdentifier];
}
}
return networkInfo.currentRadioAccessTechnology;
}

@end

0 comments on commit b65a783

Please sign in to comment.