Many Locale properties can return zero for various reasons on iOS (and Android).
You can also use objectForKey:NSLocaleCountryCode to request a country code.
It would be a good idea to have fallback logic for finding countryCode with CoreTelephony.
CTCarrier *carrier = [[CTTelephonyNetworkInfo new] subscriberCellularProvider]; NSString *countryCode = carrier.isoCountryCode;
Or / And with reverse geocode:
// CLLocationManagerDelegate - (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray<CLLocation *> *)locations { __block CLLocation *location = [locations firstObject]; [[[CLGeocoder alloc] init] reverseGeocodeLocation:location completionHandler:^(NSArray<CLPlacemark *> * _Nullable placemarks, NSError * _Nullable error) { if (!error && placemarks.count > 0) { CLPlacemark *placemark = [placemarks firstObject]; // Use placemark.country; // Use placemark.ISOCountryCode; } } }
For example, in the Android version of the corresponding region query for Locale, this is nil for many root devices.
source share