Find current country from iPhone device Find current country from iPhone device ios ios

Find current country from iPhone device


To find the country of the user's chosen language:

NSLocale *currentLocale = [NSLocale currentLocale];  // get the current locale.NSString *countryCode = [currentLocale objectForKey:NSLocaleCountryCode];// get country code, e.g. ES (Spain), FR (France), etc.

In Swift:

let currentLocale = NSLocale.currentLocale()let countryCode = currentLocale.objectForKey(NSLocaleCountryCode) as? String

If you want to find the country code of the current timezone, see @chings228's answer.

If you want to find the country code of the device's physical location, you will need CoreLocation with reverse geocoding. See this question for detail: How can I get current location from user in iOS


NSLocale *locale = [NSLocale currentLocale];NSString *countryCode = [locale objectForKey: NSLocaleCountryCode];NSString *country = [locale displayNameForKey: NSLocaleCountryCode value: countryCode];


For devices with SIM card you can use this:

  CTTelephonyNetworkInfo * network_Info = [CTTelephonyNetworkInfo new];  CTCarrier * carrier = network_Info.subscriberCellularProvider;  NSString  * countryCode = [carrier.isoCountryCode uppercaseString];