当前位置: 动力学知识库 > 问答 > 编程问答 >

iphone - iOS Get Country Where The Device User Is Located

问题描述:

We’re developing an iOS app. One requirement we have is, get the country of the user location to enforce restrictions in the app. One solution we’re thinking about is to gather the IP address and use it with a Geo-localization service to get the country. One partner told us that this kind of solution violates Apple policies. Could someone confirm this statement? Or, someone knows another way to gather just the country where the device user is located?

网友答案:

Use the Apple-provided location services to find the location of the user. It's by far more accurate than geocoding from IP addresses, it doesn't require a third party service (or your own service) and it provides an estimated Latitude and Longitude for the user that you can use on a map or similar.

网友答案:

Using the Apple-provided location services is only part of the solution. Since location services does not return a country you will need to use a service that takes the latitude and longitude to determine countries nearby. I have used this before for other purposes, but querying something like this web service with the latitude and longitude should return you a country nearby.

http://ws.geonames.org/findNearby?lat=47.3&lng=9

网友答案:

Apple has a reverse Geocoder API now CLGeocoder. It will convert longitude and latitude to a user-friendly representation. I would use the location services and CLGeocoder to get this information, so you won't have any problems later and don't need any third party API's.

https://developer.apple.com/library/ios/#DOCUMENTATION/CoreLocation/Reference/CLGeocoder_class/Reference/Reference.html#//apple_ref/occ/cl/CLGeocoder

网友答案:

You could use Google Reverse Geocoding API to get the country named based on the user location coordinates

分享给朋友:
您可能感兴趣的文章:
随机阅读: