In my iOS App, I need to obtain the user current country.
I know that I can use CLLocation
to retrieve the location and then reverseGeocodeLocation
to get the country, but it will not work if the user doesn't authorize my app to get his location.
I could maybe use (Locale.current as NSLocale).object(forKey: NSLocale.Key.countryCode)
;
but I wonder if the countryCode change when the user travels or only when he manually change his settings?
Is it possible to retrieve this information from the current carrier operator ?
You can find the country code using carrier by using this
CTTelephonyNetworkInfo *netInfo = [[CTTelephonyNetworkInfo alloc] init];
CTCarrier *carrier = [netInfo subscriberCellularProvider];
NSString *mcc = [carrier mobileCountryCode];