Is it possible to get the users country without performing a geocode request?
In my app I want to have some default settings if the users is from the us (imperial system) and if from any other country I want to use the metric system as default.
It would be great if I could know the region format the phone (iphone) is set to or something like that. If not I guess I could always perform a geo request to determine the country.
I'm looking for the same thing. There is a way to do it on the iPhone in object-c so hopefully if not already, the Appcelerator team will look into an implementation. I'm guessing there is a similar way on the Android.
I realize I'm posting Objective-C, but just in case an Appcelerator developer decides to implement it, I'll put a couple ways I've seen to do it….
NSLocale *locale = [NSLocale currentLocale]; NSString *countryCode = [locale objectForKey: NSLocaleCountryCode]; NSString *countryName = [locale displayNameForKey: NSLocaleCountryCode value: countryCode];
Method 2: (iOS 4+)
#import <CoreTelephony/CTTelephonyNetworkInfo.h> #import <CoreTelephony/CTCarrier.h> CTTelephonyNetworkInfo *netInfo = [[CTTelephonyNetworkInfo alloc] init]; CTCarrier *carrier = [netInfo subscriberCellularProvider]; NSString *mcc = [carrier mobileCountryCode];
Maybe you can open a hidden webview including MaxMind JS api:
Country Code: TR
Country Name: Turkey
I was hoping to be able to do this without the need to perform a web request. If I need to do this I would use the google geocoding service which turns a lat,lng from the gps into a location: http://maps.googleapis.com/maps/api/geocode/json?latlng=40.714224,-73.961452&sensor=true
I guess this might be the way to go for me.