Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Detecting home country of Windows Phone 7

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).

like image 797
Stan Avatar asked Mar 07 '11 17:03

Stan


2 Answers

You can't get the country, but you should be able to guess it from:

  • the Locale of the device - see How to get "region & language" settings in WP7 via code?
  • or from the TimeZone of the device - see TimeZoneInfo.Local - http://msdn.microsoft.com/en-us/library/system.timezoneinfo.local.aspx

Personally, I wouldn't worry about the travelling scenario - travelling Americans purchasing your app represents a very small percentage of your downloads.

like image 156
Stuart Avatar answered Oct 25 '22 04:10

Stuart


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.

like image 36
Martin Avatar answered Oct 25 '22 03:10

Martin