Reputation: 746
Is there a way to programmatically find out what country a user's phone is from when my app is opened on their phone?
I have an app I'm developing that can use lbs/kg units and if someone's phone is from the United States, I want to enable lbs by default and if the phone is from anywhere else, I want to display kg by default. (note that I don't need think checking where they are connecting from would be accurate because it could be that they are travelling or using another country's proxy server).
Upvotes: 7
Views: 1907
Reputation: 637
Why not just look at System.Globalization.RegionInfo.CurrentRegion.IsMetric?
There is an example here: http://msdn.microsoft.com/en-us/library/windowsphone/develop/system.globalization.regioninfo.ismetric(v=vs.105).aspx
Upvotes: 0
Reputation: 11041
You could also use the GPS to get their current position, then use the Bing API to get the country from the lat/long.
Using the GPS involves it's own headaches like adding a Privacy Policy, but from Stuart's answer, it seems like the most accurate way.
Upvotes: 2
Reputation: 66882
You can't get the country, but you should be able to guess it from:
Personally, I wouldn't worry about the travelling scenario - travelling Americans purchasing your app represents a very small percentage of your downloads.
Upvotes: 7