Retrieving data of Nearby devices containing same application - ios

I'm developing a chat application, and a requirement is to get the device details for users within some distance (i.e., devices within 100 miles who are using same application). I want to get the details and they should be shown in a UITableView.

There are far too many pieces involved in this for a single answer to include all the code, however I can give you a high-level overview:
You'll need to send the device's current location (found with CLLocationManager) and an identifier to a remote server on applicationDidBecomeActive: and whenever you determine that the user has moved a significant distance.
Your remote server stores these coordinates, the identifier, and a timestamp into a database table and periodically prunes old entries.
When you load the "Nearby Users" screen your devices makes a request with its own location to the server, which returns the list of users within 100 miles. The Haversine formula is the proper way to calculate distances between GPS coordinates. Once you have the results, you can show them in a UITableView.
When the user selects a nearby user, you can use the identifier it sent in step 1 to start brokering a connection between them. This part is highly dependent on your specific chat system.

Related

react native share geolocation with other device

Is it possible to share user's location to other user (of the same app)? I want to build a geolocation sharing app that pings/notifies user A once user B has crossed a certain radius. Doable with firebase or a similar third party? thank you in advance
Let me see if I understand, what you want to do is:
1 - If user A passes near user B (on the street), notify both users that they are nearby?
2 - Do you want to share the user's location through an application and send it to another user, either through a social network or email?
If it is option 1, you will have to obtain the latitude, longitude and accuracy of the users and keep sending and obtaining it from Firebase every so often (or through a socket connection like socket.io) and make a match and calculate the radius or distance between both points.

iOS - Allow all users to find map pins near them

I'm making an iOS app where users are able to place a pin (CLLocation) on a map and all other users within x miles of that point will be able to see it on a map. How can I do this?
1) User places a pin on the map -> pin placing function sends a message to a server with latitude, longitude, and the annotation name.
2) Server checks what users are within the radius -> Sends silent notification to users.
3) Local apps drop a pin.
OR
2) Server sends a silent notification to all users (containing the latitude, longitude).
3) Local instances of app decide whether or not to drop a pin on the location.
Basically you have a fair bit of choice here - should users need to constantly update servers with their location, and only the relevant users get sent a notification? Or do you want all users to receive a notification and the app to decide if a notification should be dropped.
A simplistic view of one possible solution could have three major components:
The client-side app which allows users to view and place pins.
A server-side app which receives locations from and sends pins to many clients.
A database which stores all of the known pins.
The question then suggests two sequences of interest:
Creating a pin:
A user creates a pin on a client app. The client app sends a description of that pin to the server (this is often an HTTP POST request but there are many options).
The server receives this request, validates that it understands the description of the pin and that the client has permission to create it, converts it into a format convenient for storage in a database and sends it to the database.
The database adds the new pin information to its list of known pins.
The server responds to the client's request with a "success" message confirming that the pin was saved.
Viewing pins:
A client app needs to show nearby pins (because a user launched the app, or switched to a map view, or the app received a notification, or whatever). The client sends a request to the server asking which asks for all visible pins and which includes the client's location. (You can decide if the client also get's to define what distance counts as "nearby" or not.) (If creating a pin used an HTTP POST then this is probably a HTTP GET but again there are many options.)
The server receives this request, determines if it should share pin information with this user, and if so constructs a query which will obtain all "nearby" pins from the database.
The database responds to this query with information about 0 to many pins.
The server converts the database representation of these pins into a format the client app can understand and sends a response containing these pins. (As the set of pins becomes very large this may become more complicated; the server might only return some of the nearby pins and information about how many more were not included, the client could then get another "page" of results in a second request.)
There are many decisions to make along the way and many tools to choose from to build all of these pieces. There are many programming languages you could use to write the server-side component (and many frameworks written in those languages which try to make building certain types of web applications easier). There are many data formats you might use to exchange information and many databases you might use to store these data (some of which have built in support for the sort of geolocation math you would need to determine which pins are "near" a given latitude and longitude).

iOS with Parse: users tracking each other

Please suggest the most efficient approach to implement different users tracking each other on the map, so every user can see others current location and they can see his.
For example: if one user moves, other immediately see his new location and vice versa. If the user moves and new users appear in his vicinity, they are tracked.
I would like to use Parse as a backend for this.
I tried the approach of saving new location on didUpdateUserLocationand then running a query in background, configured as myQuery.whereKey("location", nearGeoPoint: currentGeoPoint, withinKilometers: 0.5)
It works but apparently uses lots of bandwidth, as even a small change in user location triggers a query to Parse (and i see internet activity indicator on iPhone status bar working all the time).
So i have a feeling that it can be way more efficient.
Should i use push notifications instead?
If so, what would be the implementation in general?
Thanks a lot!
If you want to monitor location changes in realtime, then this will of course require a substantial amount of interaction with the remote server. While Parse may or may not be a good backend for this task, you should keep in mind that, if you are using the free plan, you have a limit of 30 API requests/second (and this may easily be exceeded in this scenario when you have multiple users).
Limiting the updates to significant location changes may be a reasonable compromise, as described in the documentation. Here, you would get a new location when the user moved ~500m, but this could of course be the downside when you want to literally follow the user in person.
Using push notifications to inform other users of a user's location changes might be more efficient:
send a push notification to the followers once a user changes
her/his location. This would mean one request for each location
change.
update other users' location changes when your own
location changes. Here you would have two requests for each location
change.
Using 1, you would still get updates from other users, even when you are not on the move. Note that these requests are counted for the device, not for Parse. I.e. Parse includes sending push notifications in the request limit.

xCode show app users on inapp map services

I've recently started to learn how to develop with Xcode and I have a question about the map and gps services.
Does anyone know what kind of resources I would have to use if I wanted to have a map in my app that shows the location of other people who use the app?
I have a general idea that each person would need an account for my app,
But would I have to put everyone's gps coordinates onto a server (SQLite?) and then constantly make the app fetch this information?
I am aiming for a similar concept that the app Called "Uber" uses where you can see taxi drivers around you and they are moving.
Yeah, you will probably need to store each user's GPS coordinates somewhere in a database. Then you can draw annotations on Apple's map view or on a map view that Google provides in their iOS helper once you fetch information from the database. I would not constantly update the user's map though. You should update it every 5 minutes, or when the user asks for it to be refreshed either through a button or some other form. Also if you plan to find the nearest user to them from the database I recommend using the Haversine Forumula (http://rosettacode.org/wiki/Haversine_formula).

GPS location tracking of others in Corona SDK

I am building an iOS app in Corona SDK and am trying to implement a map feature where the user can see where they are compared to where others with the app open are. What would be the best way to go at this?
I already wrote the code for finding the current location of the owner of the device, but how do I retrieve data from other users?
Any advice is greatly appreciated!
This is very broad question, but basically you need a server (on the web) where each user's location gets stored while the app is open, and the app can request the location of other users specifically, at some time interval. Presumably you would need to have some form of rights management since every user would typically be interested in seeing only a small number of other users, and every user would want to have control over who can see their location.
One thing to remind users of is that the reported position is that of the device, not that of the user, and that it is the last reported position, not necessarily current (not all devices are on cellular network or wifi at every moment), so you'd also want a time-of-last-update to be shown with every location marker.

Resources