Determine iPhone Country

I need to determine at startup what country the user is in for the iPhone application. Presumably, I will have to turn on location services and do some kind of reverse geocoding. I really do not want to use a third-party web service, if possible, are there any other suggestions for determining the country from which service providers provide?

At first I only need to check if the user is inside the USA or not, but this may change in the future to add more countries. I understand that a location cannot always be determined or that location services may be disabled for a user. Basically, I just need to know if the user is detected as being inside the US in order to disable a certain function.

EDIT: on further reading, it seems that MKReverseGeocoder is the way to go, except that I don't want to display any cards in my application, which means that I am not allowed to use this.

+25
iphone geolocation reverse-geocoding
Jun 15 '10 at 7:40
source share
5 answers

Given the limitations of MKReverseGeocoder, it seems that the only possible way for me to achieve what I want is to use a third-party service to execute the reverse geocode. I decided to go with GeoNames as they seem like a standard choice.

+4
Jun 21 '10 at 7:17
source share

Another trick you can try is to check the MCC carriers:

#import <CoreTelephony/CTTelephonyNetworkInfo.h> #import <CoreTelephony/CTCarrier.h> CTTelephonyNetworkInfo *netInfo = [[CTTelephonyNetworkInfo alloc] init]; CTCarrier *carrier = [netInfo subscriberCellularProvider]; NSString *mcc = [carrier mobileCountryCode]; 
+32
Jun 15 '10 at 11:30
source share
 NSLocale *locale = [NSLocale currentLocale]; NSString *countryCode = [locale objectForKey: NSLocaleCountryCode]; NSString *countryName = [locale displayNameForKey: NSLocaleCountryCode value: countryCode]; 
+22
Jun 21 '10 at 9:54 on
source share

An NSLocale object, for example, returned by [NSLocale systemLocale], and [NSLocale autoupdatingCurrentLocale] `), contains the value of NSLocaleCountryCode. Check it out in the Apple documentation.

+2
Jun 16 '10 at 2:44
source share

If you do not want to use the Google services provided by the iPhone SDK, could you just save the coordinates of US of A and check if you are inside this?

Here is the relevant question in this case. How to determine if a 2D point is inside the polygon?

If the purpose of the restriction is something other than user experience (for example, to ensure the complication of some US laws), that is, when the user cannot be started, I would say that you need a more stringent check (after all, the user would simply prohibit the use of services otherwise, right?).

One such approach would be to search by IP address, for example. http://www.maxmind.com/app/geoip_country

+1
Jun 15 '10 at 9:41
source share



All Articles