I have an application that needs to find out the country code on the phone number that the user has. I understand that I canβt just get the user's phone number, but is there a way, for example, if I have a phone number in the USA to get the country code +1?
I found several answers stating that using basic telephony you can get the country code "+1", but I tried several, and none of them work.
I tried this:
CTTelephonyNetworkInfo *network_Info = [CTTelephonyNetworkInfo new]; CTCarrier *carrier = network_Info.subscriberCellularProvider; NSString *mnc = [carrier mobileNetworkCode]; NSString *mcc = [carrier mobileCountryCode]; NSLog(@"country code is: %@, mnc: %@, mcc: %@", carrier.mobileCountryCode, mnc, mcc);
which prints:
"country code is: 310, mnc: 410, mcc: 310"
So, for an American number, I would like to get +1.
Is there any way to do this?
EDIT: On a further search, I found this:
How to match MCC + MNC with the country code of a user's phone in iOS objective-C without using location information?
This might do the trick, but I was looking for a more formal way to do it.
source share