Reputation: 947
Basically what I'm trying to do is search the itunes store for books, and display them for the user to choose from. When the user clicks on a book, he is redirected to this book itunes page.
The problem is: I'm searching for books in the "us" country. When the user opens one of the books, he can't see the book's page if his itunes account is linked to a country other than the US. If he changes his itunes account associated country to the US, he can see the book.
The challenge is to get his country in app, and search itunes for books in his country, and then open itunes, which will work considering that all requests were made for the same country.
Anyone has an idea?
P.S. can't use NSLocale, because it won't return the correct country. For example, ur itunes account could be linked to France, but ur locale may return en_us
Upvotes: 0
Views: 151
Reputation: 13420
You could use their IP address to determine which country they are in. This obviously won't work 100% of the time (proxies, vpns, etc.), but it covers a large number of cases.
There are databases and services on the internet (both free and paid) that contain this information.
EDIT:
The key is gracefully falling back. You ask the user what their location is when they create an account. If they answer you can use that, otherwise you try to detect later on. You can detect and say "Hey we think you are here. Is that correct?" The fact of the matter is IP Geolocation works well at the country level because of standard IP blocks. It only really starts to get fuzzy down at the city and state levels.
Upvotes: 1