Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Assuming you have the coordinates for the each online user, iterate that collection, create a CLLocation object from the coordinate data, and check that object against CLLocation method distanceFromLocation with a radius value.

https://developer.apple.com/library/ios/documentation/CoreLo...:



Yes. When the user opens the app I will get their current location and add it to a column in the database 'currentLocation' Then I will query the database like so: select * from users where userOnlineStatus = 'online' and currentLocation = ""; <- That is what I would want to do. Its just calculating the distance so that not all random users are showing up.


Also as @mtmail mentions, the better path for this is probably not on the device itself. It would get expensive where N number of users is really high. Perhaps at the service layer, send the device location to the service, and have the service return the nearby users.




Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: