5. Location - nimitd/SafetyAppPublic GitHub Wiki

Overview

The location sharing feature of our app allows users to share their real-time locations with one another. This sharing persists indefinitely, until one of the users terminates the sharing.

This feature, while available in other apps, is uniquely cross-platform and built around Stanford's SUIDs. Regardless of whether a user is on iPhone or Android, they can share there location with any other user with only their SUID. They have the SUIDs of all members of their community available to them in the resources tab. This is especially useful for RA's and students to mutually share location (as they may not have each other's numbers) and for freshman to share their location with other freshman (as they likely just met and may not have each others' information).

To protect user privacy, sharing is not required to be mutual. That is, a user can share their location with another, without that second user having to reciprocate. Moreover, location sharing can be revoked at any time and the revocation takes effect immediately.

Front End

On the front end, we take advantage of React Native's access to the native maps framework and UI. We used the backend (described below) to build atop this native maps and populated it with markers and labels. In the first screenshot, you can see 3 buttons. There is a send icon which when pressed allows you to input an SUID to share your location with (Screenshot 2). Once hitting ok, it will start sharing your location with that user immediately.

When hitting the Who Can See Me button, a react native Modal view pops up which pulls from the database all the people who can see the user's location (Screenshot 3 and 4). Upon clicking anywhere on each item, you get a prompt asking whether you would like to confirm stop sharing location with that user. This will immediately remove you from that other person's map.

The Show all Friends button fits the map view so that you can see all the people who have shared their location with you including yourself on the map view. Maps functionality was enabled through react native's map functions such as fitToSuppliedMarkers(), Animated Regions, and the map styles provided.

Alternatively, you can click on the label on the left side of the image and the map will focus to the pin for that user!

Back End

Our location sharing component uses the subscribed_to table in the AWS database and a real time messaging service called Scaledrone, which provides pub/sub functionality through "rooms." Our layout is as follows:

Each user X is subscribed to and publishes to their own room, named “observable-” where SUID is the student ID of that user (taken from the Redux). The user regularly publishes their location to this room, notably whenever their location changes or when a new member subscribes to the room.

User X is also subscribed to the room of every other user who is currently sharing their location with user X. Information on who is user X should be subscribed to is taken from the subscribed_to table in the database (described above).

When user X decides to start or stop sharing with user Y, user X updates the database to reflect this change, and then posts an “/UPDATE” message to user Y’s room, which triggers user Y to poll the database again and reflect the changes in user Y’s app by re-rendering.

⚠️ **GitHub.com Fallback** ⚠️