I am facing some network related issue, need to check the cellular network type, like 2G,3G or 4G data network is selected.
CoreTelephony.framework
could provide you such details:
Objective-C
CTTelephonyNetworkInfo *telephonyInfo = [[CTTelephonyNetworkInfo alloc] init];
NSString *technologyString = telephonyInfo.currentRadioAccessTechnology;
if ([technologyString isEqualToString:CTRadioAccessTechnologyLTE]) {
// LTE (4G)
} else if([technologyString isEqualToString:CTRadioAccessTechnologyWCDMA]){
// 3G
} else if([technologyString isEqualToString:CTRadioAccessTechnologyEdge]) {
// EDGE (2G)
}
Swift
import CoreTelephony
let telefonyInfo = CTTelephonyNetworkInfo()
if let radioAccessTechnology = telefonyInfo.currentRadioAccessTechnology{
switch radioAccessTechnology{
case CTRadioAccessTechnologyLTE: print("LTE (4G)")
case CTRadioAccessTechnologyWCDMA: print("3G")
case CTRadioAccessTechnologyEdge: print("EDGE (2G)")
default: print("Other")
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With