Any Update?
Post
Replies
Boosts
Views
Activity
Below function we are using
static func getMccMnc() -> (mcc: String, mnc: String) {
let bgTask = UIApplication.shared.beginBackgroundTask {
print("BackgroundTask Expired")
}
let networkInfo = CTTelephonyNetworkInfo()
var carrier: [String:CTCarrier]? = nil
if #available(iOS 13.0, *) {
guard let str = networkInfo.dataServiceIdentifier else {
UIApplication.shared.endBackgroundTask(bgTask)
return ("","") }
carrier = networkInfo.serviceSubscriberCellularProviders
let ctCarrier = carrier?[str]
guard let _ = ctCarrier?.mobileCountryCode, let _ = ctCarrier?.mobileNetworkCode else {
UIApplication.shared.endBackgroundTask(bgTask)
return ("","")}
UIApplication.shared.endBackgroundTask(bgTask)
return ((ctCarrier?.mobileCountryCode ?? ""), (ctCarrier?.mobileNetworkCode ?? ""))
}
We are using this to get the MCC & MNC let networkInfo = CTTelephonyNetworkInfo() var carrier: [String:CTCarrier]? = nil if #available(iOS 13.0, *) { guard let str = networkInfo.dataServiceIdentifier else { UIApplication.shared.endBackgroundTask(bgTask) return ("","") } carrier = networkInfo.serviceSubscriberCellularProviders let ctCarrier = carrier?[str] guard let _ = ctCarrier?.mobileCountryCode, let _ = ctCarrier?.mobileNetworkCode else { UIApplication.shared.endBackgroundTask(bgTask) return ("","")} UIApplication.shared.endBackgroundTask(bgTask) //NewChanges return ((ctCarrier?.mobileCountryCode ?? ""), (ctCarrier?.mobileNetworkCode ?? ""))}
This code give wrong MNC in Roaming