Find nearby users of an app (iPhone and Android)

14,738

Solution 1

Even i had this question on my mind today while creating similar app. Alert when two users/friends are near to each other - Android Proximity

after spending a couple of hours thinking, I thought a better way to do this :

1) Create SharedPreference / DB which holds the last Coordinates of the device which was also updated to the server.

2) Create Service which will fire once in 15 minutes requesting current location.

3) If the current location matches the Last Location retrieved from the SharedPreference and or around within proximity (depends on how much u give 30ft or more) then user is in the same place so don't upload the coordinates to the server.

4) If the user isn't within proximity or last location doesn't match current location then upload the coordinates to the server.

5) After uploading coordinates to the server, update SharedPreference too..

6) After uploading, return response of Users details from the server who are nearby the same coordinates. The User will then get notified if someone around them..

Solution 2

Every update you do will cost battery and data. If you do this too much, you will certainly annoy users by being a resource hog.

I'd suggest creating a service that is called periodically, to update the user's location on the server, and get a list of nearby users from the web server. The frequency of updates should depend on the speed the user was traveling at during their last update. If they weren't moving, 15 minutes is probably alright, if they were going at car speeds, more often is necessary.

In order to store the users locations on the web server, I'd suggest using a purpose built GIS package that actually understands what a location coordinate is. Most databases have something like this built in. Then, when the app requests a list of nearby users, the app only needs to receive the users that are actually nearby, and the others can be ignored, saving some data, and the work of doing distance calculations on the phone.

Solution 3

you should consider following possible issues.

  1. If application keep on sending user's location then the user battery will getting down, and web server memory will increase.

  2. Application will keep on use internet to send location to web server.

  3. At the time of roaming internet data cost may increase.

my suggestions:

  1. The app should send the user's location every 15 minutes.

  2. Every application should use unique id to update their location.

  3. If application closed then clear that app's location in web server.

Share:
14,738
Atif Azad
Author by

Atif Azad

Senior Software Engineer Coeus Solutions GmbH

Updated on June 03, 2022

Comments

  • Atif Azad
    Atif Azad about 2 years

    I am working on an app that has an iPhone version as well as an Android version.

    My goal is...

    • display a list of nearby users of my app (iPhone app users and Android app users). Lets say a list users which are currently within 1 mile or 2 miles radius and are currently using my app.
    • This list will display on both apps, iPhone app and Android app.
    • App will update the list when user clicks a Refresh button.

    My question is...

    • What is the best way to accomplish above stated goal? Do I need to periodically send current GPS location of all users of app from their Droids and iPhones to our web server?

    To make my question more clear...

    • I have an algorithm to find out the places/users within a given range (1 mile or 2 miles radius etc), so PLEASE DON'T TELL ME how to find users within a given range.
    • I know how to get current location of iPhone and Droid devices, so PLEASE DON'T TELL ME how to get updated location of an iPhone or Android device.
    • I know that this is a privacy issue. Therefore app will ask for user's permission to send their location to our web server, so PLEASE DON'T TELL ME about privacy concerns users or Apple may have.
    • JUST TELL ME how to best maintain updated list of Geo Locations of my app users on the web server? The best, proven approach!
    • Let me know if my question still needs clarification.

    Thanks and best regards

  • Atif Azad
    Atif Azad over 12 years
    Thanks for the suggestions! But if you are driving, your location changes fast. Updating every 15 minutes will not help users find other people near them. I want quicker updates, more realtime location data. How to be efficient in this scenario. I am aware that updating the server that quickly will have certain issues as you have mentioned them yourself too. Actually this is the main reason I posted this question.
  • Atif Azad
    Atif Azad over 12 years
    Very helpful JeffS... We are building our web server app in C#. I am not familiar with GIS packages. Can you help me more on this? How can we use GIS packages with MS SQL Server? Does MS SQL Server have such support built-in?
  • JeffS
    JeffS over 12 years
    I know pretty little about the MS world as far as server side world, but I believe that SQL Server 2008 came with geospatial capabilities, and that would be a good place to start.
  • Jethro
    Jethro over 8 years
    Appears the link is broken :(
  • sweepez
    sweepez almost 8 years
    How do you implement step6. step1-through-5 are pretty straight forward.