iOS Find Other Nearby Devices (GPS locations) - iphone

I have an app that allows a user to transmit their location to a server. What I am trying to do is have the user press a button that will send a push notification to anyone with the app within lets say a 3 mile radius. Can someone give me an overview of how I can accomplish this.
The only way I could think of doing this is publishing the gps coords to a server. Then when the user presses "Send notif" a message gets sent to the server, then the server does some complex proximity search based upon the location and then returns the values to the user.
My problem is, I have no server-side experience and have no idea how to program a GPS search algorithm on the server.
Is there a way for me to do what I want without having to write code on a server? I am able to use Parse to store the GPS coordinates. I'd like to keep my server code to simply storing and retrieving values and handle everything else client side.
Thoughts?

Each device should send their GPS coordinates to the server periodically. I think you already have this step. The next step is to find devices that are near each other. This is fairly simple.
Distance Between Two Latitude and Longitude Points
However, if you have millions of devices, it will be a problem of scale if you compare each update to all the other devices. You might bucket the devices to a certain area. For example, you might bucket the updates into 100 square mile areas. When an update comes in you need to only compare to those devies in that bucket plus adjacent buckets if they are near the edge. This is just top of the head analysis but hopefully it will point you in the right direction.

If you really want to put all the load on the client (iOS) side:
Query the server for IDs and locations of all possible recipients for the push notification
Store ID and Location in custom object and put those in a NSArray or a NSSet
Then
//otherUsers is the NSArray or NSSet with custom objects
//currentLocation is the users current location
for(MYCustomUser * otherUser in otherUsers) {
if([currentLocation distanceFromLocation:[otherUser location]] < 4829) { //4828 == 3 Miles in Meters, so 4829 is 3 Miles + one Meter
//send msg to server to perform push notf. to user
}
}
Done...
you should put this in a NSOperationQueue so that is can run in background an is not blocking the device
But as bbarnhart said... it's not very wise to put all this on a device.

Related

How to implement miles away like Tinder in Swift

I am trying to calculate how many miles away the user is from another user. Like on Tinder.
I am using Firebase to store all of the users data related to the app.
What would be the most secure way to do this without storing the actual users current location?
You need to get the current location, and after calculating the distance or after the user logs out, delete the location from the database. That is the only way to do it.
Note that this will work only if both users are online at the same time.

Changing a UITableViewController dynamically via location

I am in the process of building an app, for the record I am using the code from the ECSlidingView controller. I would like for my app to use the GPS to pull data from my web interface letting the user know that they can do certain things at a given location. So for example, I have a user go to a store and lets say I want them to make a payment at that location, it will given them that option. Or if the store doesn't offer payment through the app, I disable that. What would be a good way to go about this?
You could try using CoreLocation but you might have trouble getting accurate location inside (it will most probably use wifi or cellular info so the accuracy might not be what you expect). Then, when you get the location, issue a request to your service passing latitude and longiude you receive from CoreLocation. There, you should search by location to retrieve possible matches - consider returning muliple store infos for nearby stores due to the accuracy issues.

Best practice for sending live location data to server from iPhone

I want to develop an application for the iphone, that tracks the current position of the user in "realtime" and sends this data to a sql database on a webserver by a web service, so I will be able to have a consistent database where the registered users a currently positioned.
This is raising some questions on how to do this in an efficient way.
1) Shall I really update the GPS data in realtime on the server? Isn't this to "heavy" regarding energy consumption on the iphone? Maybe once a minute does it as well? What are best practices here when I want to be as accurate as possible?
2) What if there a maybe 1000 users at once.... is this still efficient to update a database with the current GPS data simultaneously?
Thank you in advance
Sebastian
Sending GPS data at regular time intervals will put extra load on the system unnecessarily and it is not optimal.
A better way to track the user is to send data only when the user has moved outside a circle of radius R from the last reported location.
That way a user moving in a car at 60 mph on a highway and one walking at 0.1 mph in a park will both be tracked accurately.
Users are known to stop moving when they sit down to eat, go to the bathroom or sleep.

Geolocation in Iphone Application

I am a newbee to Iphone App Development and struggling with my first application.
I have a database with few address in it. All I have to do is get the current location and pick the closest three address from the database and of-course have to show the current location and the selected three nearest address on a map with directions on them.
I had a look at the Xcode frameworks LocateMe, CurrentAddress and MKReverseGeocoder Class Reference.
But then not sure how to co-ordinate this all together in an orderly manner.
Any suggestions/assistance would be greatly appreciated.
Thanks
You should provide lat/lon with your addresses in your database, so do the geocoding of the addresses before.
You have a location manager (CLLocationManager) which takes care of your current position, and with each location (CLLocation) you can calculate the distance (distanceFormLocation:). Now you only need to sort your database with this and pick the first three items.
Hmm?

I'm trying to understand the concept of pulling information off the web and into an app Please!

Generally speaking, how does an app like "Around Me" acquire the information it displays?
For example: the restaurants that show up in a list that are near me with the address and distance (I think I get the distance piece) where is this information extracted from? Is it Google or something?
I'm not asking how to implement this (that's over my head!) just get an idea of how it occurs.
Thanks StackOverFlow people.
I haven't seen that specific app, but most such apps either have an embedded database of locations or they dynamically query a server back-end (e.g. using HTTP) to fetch a set of locations near you. They know where you are because the app has access to location services to find out your geographic location.
The iPhone has a GPS unit which gives you your latitude and longitude, which it then sends to a backend server (Say Google Maps) and queries it for, in your case a restaurant. The server responds with a set of locations around you.