問題描述
對于 iPhone 應用程序,我需要在啟動時確定用戶所在的國家/地區.大概我將不得不打開位置服務并進行某種反向地理編碼.如果可能的話,我真的不想使用第三方網絡服務,是否有任何其他建議可以根據位置服務提供的內容來確定國家/地區?
I need to determine at startup what country a user is in, for an iPhone application. Presumably I will have to turn on location services and do some sort of reverse geocoding. I don't really want to use a third party web service if possible, are there any other suggestions for determining country from what location services provides?
最初,我只需要檢查用戶是否在美國境內,但將來可能會更改以添加更多國家/地區.我了解無法始終確定位置,或者用戶可能關閉了位置服務.基本上,我只需要知道是否檢測到用戶在美國境內,以便關閉特定功能.
Initially, I only need to check whether the user is inside the US or not, but this may change in the future to add more countries. I understand that location can not always be determined or the user may have location services turned off. Basically, I just need to know if the user is detected as being inside the US, in order to turn off a specific feature.
在進一步閱讀中,看起來 MKReverseGeocoder 將是可行的方法,但我不希望在我的應用程序中顯示任何地圖,這意味著我不允許使用它.
On further reading, it looks like MKReverseGeocoder would be the way to go, except I don't wish to display any maps in my app, which means I'm not allowed to use this.
推薦答案
鑒于 MKReverseGeocoder 的限制,我想實現我所追求的唯一可行的方法是使用第三方服務執行反向地理編碼.我選擇使用 GeoNames,因為它們似乎是標準選擇.
Given the restrictions of MKReverseGeocoder, it seems the only feasible way for me to achieve what I am after is to use a third party service to perform a reverse geocode. I have chosen to go with GeoNames as they seem to be the standard choice.
這篇關于確定 iPhone 用戶所在的國家的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!