Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Kane Montreuil
4,693 PointsWhat is the best way to determine if users are 'nearby' you in an iOS application?
I'm hoping to build an iOS application that allows users to search if any others using the application are within a predetermined radius (ex. 1 mile) of them using GPS. I was thinking of uploading all users current location to a database then have some sort of application on a server do comparisons to see who is in proximity to each other when requested.
1 Answer
Dominic Bryan
14,452 PointsKane Montreuil this is interesting and not as difficult as you are making it sound ahah. When building the app you have to request permission to find current location of the user whilst the app is running or in the background(all the time). The location will be in latitude and longitude but you would simply set the current users app to show any users that got with in a certain area (say plus 10 latitude and longitude, so any user that was roughly the same latitude and longitude). It would take some intuitive thinking to get it working but its possible, the only floor I see in this is getting users that will use allow Location Settings Always (kinda creepy thinking you are being tracked) when launching the app. And by the way you cant trick people, if you have gps you have to use this or it wont pass apple review for store.
Kane Montreuil
4,693 PointsKane Montreuil
4,693 PointsThanks for the answer Dominic Bryan! That is the solution I came up with initially, but later threw it out in hopes there has to be a simpler way which is why I'm here asking the brilliant Treehouse students. The issue with simply adding 10 latitude and longitude is because of the spherical shape of the earth. Longitude and latitude are great for pinpointing an exact point on the earth but not so good (without some calculations) for determining a radius. For example, 10 degrees of latitude will get you much farther in Africa than it will in Antartica, that is unless my understanding of latitude and longitude is fundamentally wrong. (: The other issue with simply adding 10 latitude and longitude is that gives you a square more or less, rather than a radius. It's interesting we both came to the same conclusion, though! Thanks again for the response.