Request routing on iPhone/iPod without GPS - iphone

I want to build an iPhone App that should contact a server that is nearest to its location.
The app itself knows where the servers are located and it should find out which one to choose.
Because I expect many users with an iPod touch I can't use GPS to do this.
On StackOverflow and ServerFault I found this possible solutions:
Use Anycast technology to route users => I can't use this method because the device itself should route the requests and know where they are going.
Get country code and use the Google Directions API to determinate which server is nearest.
Get location by IP (GeoDNS etc.) and do the same (see above).
Method 2 seems good but I have three questions to that:
The API sends me the whole route from point x to point z. I just want to have distance. Is there a way to do that?
Google says they have a usage limit of 2,500 request per day. How do they control that? By IP? I ask this because they say you don't have to use an API key - how do they control then?
Is is a good idea to use Google without having any trouble later? My app itself will be free but I'll have In-App Purchases in it. Does that matter?
I hope somebody has experience in this. Thanks in advance!
Paul

In many cases, iOS will still return a location when requested on devices without GPS. Remember, the first generation iPhone didn't have GPS, but could still do location based services. iOS will use a number of techniques (IP geolocation, skyhook, etc) to find the location of a user, in addition to GPS.
Anyway, to answer some of your questions:
The 2,500 requests per day is per end user, or typically per IP address. So you shouldn't need to worry about getting capped. You should however be aware that you need to display a Google Map to use the API, so if you're using their API and not using a mapView you may have an issue.
I'm not entirely sure why you would need to use the Google directions API in the first place. If you can get lat/lon coordinates of both the user's current location and your servers you can just use iOS's built-in CoreLocation methods to get the distance between them, and decide accordingly ([CLLocation getDistanceFromLocation]).

Related

Best way to build a proximity app within 200 meter range of the user?

I am using Swift to develop a personal app for my family and have been researching methods of what toolset to use to build an app that allows a user to see other people using the same app in a vicinity of around 0 - 200meters.
I was looking at bluetooth and also trying to work out how Tinder finds other users. Do they just use GPS? If so how would one best implement that.
What would be the most effective way to determine another users location within 200 meters?
Note: 1 user would search the surrounding area for any devices that are on the app - Then it would tell the user their location. So it is doing both, finding the distance between the two locations and how you should get to that location. Obviously as this is for personal use, security issues arent much of a concern.
As you may have expected, you have many options of different approaches that will all accomplish your goal. I suggest you start by taking a look at a couple open-source projects:
PeerKit
LocationChat
Both of these libraries demonstrate a way to transfer a payload of data between devices. In addition, both projects provide very helpful example apps.
Assuming you choose to use PeerKit, each device could be responsible for obtaining its own location (via CoreLocation) and then broadcasting it to other devices (via PeerKit). Then the receiving device will be able to calculate the distance between itself and its nearby peers.
Note: At the time of writing, I have not contributed to either of the projects suggested above.

Find iPhone devices/device tokens in specific radius :-

I want to find iPhone devices/device tokens within a specific radius from particular location.
For example : Within a 25 K.M. of radius from Sydney,i want to get iPhone devices tokens.
I am working on ASP.NET MVC2 for this.
Let me know,if is there any API for that?
Thanks,
You are only able to get details for devices that you 'know' about. Your app will need to log unique IDs for each device, and your app will need to log known locations for devices. It's then up to you to look up, from your central database, the details of the devices within a certain distance. iPhones can update significant location changes when running in the background but it's up to you to track devices and accept the limitations that that data may not always be correct. eg. If a user falls outside connectivity then you will still have an old location logged for that user.
I'm not aware of a single API that offers this services, if you're coding it then in your app you will need to register devices identifiers and location information to a central server. You will also need to create the lookup to query your data to find devices within a location. I am guessing that you might want to send push notifications, in which case your app will also need to register for notification services too.
There is no way for you to discover devices that don't have your app running and you also do not know who the owner is.

iOS api for real time traffic data (like geoloqi and Waze)

I have been visiting some services api website but can't find what I am looking for. My question is more aimed at what resources to use rather than how exactly it should be done.
My iphone app requirement is to be able to track users that are nearby, are commuting and locate them on map. Additional requirement maybe texting them, call them, have video session with them etc. On a high level, this will convert to something like
get user details based on longitude and latitude
get to know if they are registered users of the service subscribed
Sending message to user/users
Call user using iphone phone api or dedicated app session
Video call
Waze is one of them. While it is open source, there is quite less documentation on how one can use it as backend for real time traffic data.
Then there is this Geoloqi which is paid, but has iOS SDK as well as rich api. However I cannot find sections that are useful to me when I look up to my requirements listed above. What I believe is that there must be many apps already relying on such a useful service. If any of them are open source / tutorials, it would be most useful resource for me for feasibility of geoloqi. Geoloqi also charges users for using their api, so it is also important for me to know what features come at what price .
For the level of data/information your interested in, and the functionality, you should just make your own app, I dont think you need those APIs.
You can find and send the coordinates of the people who are using your app to your server. Then you need to determine the distance between them, to see if they are in the zone of talking, or whatever other functionality you have listed above.
To determine the distance between two people, This answer should be helpful: Calculate distance between 2 GPS coordinates

iPhone alert an alarm if stolen

We are developing an enterprise application .The phones are connected to a Wifi router. The objective is to trigger an alarm if the phone moves out of the secure area .. (outside the building)
What is the best way to check if the iPhone is always inside the building .
some of the options we tried are
1.using Wifi(continous ping to wifi network),if not trigger an alarm .
2.if coordinates change (using GPS)
Are there any other means to achieve this .
You can use Location Services in iOS 4 (with the background location feature) to determine when the phone has moved to a different location.
#indragie's idea of using Location Services is a good one. If you can be sure that the WIFI SID isn't going to change, you could probe to see which access point the iPhone is currently associated to. If you are going to ping, then a better approach is to make the system service agnostic, and simply issue an HTTP query on a regular basis to your enterprise server. The server can then have a policy language on it declaring acceptable access points (from a variety of metrics). This might be set up to allow people to take their iPhones home.
Your best bet is GPS as the phone will not be able to find its location if you rely on WiFi and the device is not connected to a WiFi network.
Check out Apple's documentation for Location Awareness capabilities here http://developer.apple.com/library/ios/#documentation/UserExperience/Conceptual/LocationAwarenessPG/CoreLocation/CoreLocation.html
You will be able to track "significant" or standard location changes in the background, details can be found here http://developer.apple.com/library/ios/#documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/BackgroundExecution/BackgroundExecution.html#//apple_ref/doc/uid/TP40007072-CH5
[edit to include]
This might be of interest to you too - http://longweekendmobile.com/2010/07/22/iphone-background-gps-accurate-to-500-meters-not-enough-for-foot-traffic/
It depends on what you want to do. Just to let the iPhone user know that he/she is moving away, using Location Services is good enough.
However, if you want to have a server that makes sure all the devices are within range, then it's more complex because your application may get suspended without a notice from a background state; in other words, you may not be able to catch the moment when your application terminates and take appropriate actions. Therefore you are going to need a heartbeat system like pinging to the server in this case.

iPhone Mapkit: How can I get a real business name/address from a longitude/latitude?

I'm writing an iPhone application and trying to determine how to find a business name/address from a user's current GPS location (longitude/latitude). For example, if someone if using the application from inside a Starbucks, how can I find this out from their location? Is there a way to do this using mapkit or any API/Webservice?
You can do this with MKReverseGeocoder by providing a MKReverseGeocoderDelegate. It's actually quite simple.
The delegate will give you all sorts of information as an MKPlacemark.
You can get an address (MKReverseGeocoder), but you can't get a business name using the iPhone native SDK. I believe that both Google and Bing provide APIs for this, but one that I like to use (and it may have the most momentum) is Foursquare's.