Closed zihejia closed 4 years ago
I also have same issue. I am new to Objective C. Can you help me in solving problem of deprecated currentRadioAccessTechnology
in CTTelephonyNetworkInfo. Xcode gives me error Replace 'currentRadioAccessTechnology' with 'serviceCurrentRadioAccessTechnology'
`- (NSString)w3cConnectionTypeFor:(CDVReachability)reachability { NetworkStatus networkStatus = [reachability currentReachabilityStatus];
switch (networkStatus) {
case NotReachable:
return @"none";
case ReachableViaWWAN:
{
BOOL isConnectionRequired = [reachability connectionRequired];
if (isConnectionRequired) {
return @"none";
} else {
if ([[[UIDevice currentDevice] systemVersion] compare:@"12.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";
}
}
case ReachableViaWiFi:
{
BOOL isConnectionRequired = [reachability connectionRequired];
if (isConnectionRequired) {
return @"none";
} else {
return @"wifi";
}
}
default:
return @"unknown";
}
} `
This will likely fix crash from
currentRadioAccessTechnology
and support Dual SIM