Actually I am trying to get the country code programatically from SimCard which is in my phone . How can we get the country code from Simcard programatically . or is there any pod that could help me get the country code details .
Thanks in advance
1. From SimCard
#import <CoreTelephony/CTTelephonyNetworkInfo.h> #import <CoreTelephony/CTCarrier.h> CTCarrier *carrier = [[CTTelephonyNetworkInfo new] subscriberCellularProvider]; NSString *countryCode = carrier.isoCountryCode; NSLog(@"countryCode: %@", countryCode);
note this is not work if
1.Airplane mode. 2.No SIM card in the device. 3.Device is outside of cellular service range.
2. From CurrentLocale
NSLocale *currentLocale = [NSLocale currentLocale]; // get the current locale. NSString *countryCode = [currentLocale objectForKey:NSLocaleCountryCode]; NSLog(@"countryCode: %@", countryCode);