Getting the operator name with CoreTelephony returns only "Carrier"

I tried to get the name of the operator with this code (using CoreTelephony):

CTTelephonyNetworkInfo *netinfo = [[CTTelephonyNetworkInfo alloc] init]; CTCarrier *carrier = [netinfo subscriberCellularProvider]; NSLog(@"Carrier Name: %@", [carrier carrierName]); 

He returns "Carrier." If I go to the iPhone settings, the operatorโ€™s name will be correctly indicated here. My iOS on the phone is v4.2.1.

What am I doing wrong?

+9
source share
2 answers

Do you really get the string "Carrier" or is the string empty ? The documentation reads:

The value for this property is zero if one of the following conditions applies:

The device is in flight mode. The device does not have a SIM card. The device is out of cellular range.

Put it blank and in the simulator.

In any case, you should check mobileNetworkCode , as the names are rarely correct (at least in Europe, where operators come and often change their names).

+2
source

Thus, you can get the code of the mobile network, the code of the country of mobile communication. From these values โ€‹โ€‹you can indicate which sim name it is.

 CTTelephonyNetworkInfo* info = [[CTTelephonyNetworkInfo alloc] init]; CTCarrier* carrier = info.subscriberCellularProvider; NSString *mobileCountryCode = carrier.mobileCountryCode; NSString *carrierName = carrier.carrierName; NSString *isoCountryCode = carrier.isoCountryCode; NSString *mobileNetworkCode = carrier.mobileNetworkCode; 

and you can make a web service for this to indicate which network operator name this parameter belongs to. these parameters can be uniquely determined from this wikipedia .

for example, my country code is "410", my operator network is "06", and it correctly identifies my operator name.

I am also stuck in the same problem and now decided

0
source

Source: https://habr.com/ru/post/888511/


All Articles