Thus, the initial requirements were that when you start the application, the mobile application will receive the exact location of the user, accurate in City. Based on the city, the server / application client will provide content related to the city.
I know that it would not be too difficult if I could use the location service (since you know that suspicious (self-observing) users usually turn off the location service for a not-so-trusted application).
I searched the Internet for several hours and get a summary of the following solutions in which I need your help to decide which one might be my best option, or if you have other best ones.
Using [NSlocale autoupdatingCurrentLocale]
minuses:
a. Explanation of the return value of the call from the Apple document: "The locale is formed from the settings for the user's system locales superimposed on any user settings that the user specified in System Preferences." What I don’t understand what is "user settings that the user specified in" System Preferences ", link link
- b
. This value can be misleading and generally not related to the actual current city / country of the user.
comments: I would appreciate it if someone could explain to me how the locale changes according to user settings.
Getting Current iPhone TimeZone
NSTimeZone *localTime = [NSTimeZone systemTimeZone]; NSLog(@"Current local timezone is %@",[localTime name]);
minuses:
- a. the same as in paragraph b above, since the user can always specify, and not allow the system to automatically update the time zone.
- b. accuracy will be indicated only in the capital.
Comments: Not very promising, but easy to implement
Using an IP- based location-based web service Based on my reading, the process will include an application sending a request to the server on which the server will record the request's IP . (Do not think that from the application itself it can get its own IP correctly, since it can be inside the local network). Based on the IP recorded through some third-party service (with IP db or some other available APIs), it will return the city information back to the client.
minuses:
- a. I have never implemented such a thing, I do not know if this is possible for a mobile application.
- b. Even if it’s possible, you don’t know if it’s faster than the location service.
comments: If you know that this is possible for an iOS application, please let me know.
Please kindly let me know any thoughts or suggest a better solution if you know.
Thank you very much.
source share