Question

I would like to check in which country the user is - I have tried a few ways but none give the requested result. My main goal is when the app launches check in which country the user is and based on this by pressing a button call a different phone number, For instance user can be in Canada use the app and by pressing the button dial an XXX number and next week with same Iphone be in the US and by pressing the same button dial a YYY number.

I have tried using CoreTelephony but this is good only for 4.0 and up i want my app to support earlier versions of iOS also tried Geocode but i do not want to display a map in my app.

Any guidance will be appreciated.

Was it helpful?

Solution

Get your current location and reverse geocode it.

Get your current location using CLLocationManager. Reverse geocoding is supported by iOS SDK 5, so if you need support versions below 5.0, you need to use external geocoding service. For example, Goolge Maps Reverse Geocoding, that is described in details here: http://code.google.com/apis/maps/documentation/geocoding/#ReverseGeocoding

What you need to do, just send a request like below: http://maps.googleapis.com/maps/api/geocode/json?latlng=40.714224,-73.961452&sensor=true and you'll get back a JSON with formatted address components.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top