Search code examples
androidfirebaseserverlocationexchange-server

Is it possible to exchange data between Android devices at distance without a server?


I'm trying to develop an app which is going to control a kid's location. The idea is:

  1. I run the app on the kid's phone and then start service which is listening to an incoming SMS event.
  2. The parent's phone sends SMS with code "where are you?"
  3. Having got the right code from the right phone number, the kid's phone finds its location and sends the location data as a SMS back to the parent.
  4. The parent's phone gets the location and shows it.

On such a condition all works well, but I'd like to send data using the net. The question is it possible to do such a task without a server? If server must be, then what will be the sipmliest way to execute that task? Should I use a chat server idea, Firebase Cloud Messaging?


Solution

  • Practically, you would need some sort of server to act as a middleman between the two. Firebase would be good, although I would not rely on Firebase Cloud Messaging for delivering the actual data (just notifying the other device that "new data" is available).

    Personally I would approach it like this:

    • Parents phone adds record to database (lets say Cloud Firestore) which says "Location has been requested for this user by this user".
    • Server sends a Push notification to the child's device which wakes the app up.
    • App checks server to see if there are any location requests in the database for the current user.
    • It finds the location request and populates the coordinates.
    • Another push notification is sent to the parents phone to wake the app up.
    • It checks the database and can see the location request has been populated.

    There are a few other steps and corners that could be cut, but that's how it would work in principal (and how it does work for a lot of applications).