0

Is there a way to find nearby devices in a WebApp - either server or client side?

I thought about JavaScript Bluetooth API, but that would require the user to pair with the other device. Another thing I thought about is using the server to determine if the requests come from the same IP/Area/... but I don't know how accurate this would be.

Do you have any other ideas or feedback about my existing ideas?

Lab Lab
  • 781
  • 10
  • 34
  • I.P address can be easily spoofed, however Javascript on certain mobile devices can access location, however the end user has to allow this – Hudson Jun 22 '18 at 13:12

3 Answers3

0

If you use the Geolocation API, it would be as simple as using the following code.

navigator.geolocation.getCurrentPosition(function(location) {
  console.log(location.coords.latitude);
  console.log(location.coords.longitude);
  console.log(location.coords.accuracy);
});

You may also be able to use Google's Client Location API.

This issue has been discussed in Is it possible to detect a mobile browser's GPS location? and Get position data from mobile browser.

Took from: Get GPS location from the web browser (Added Credit)

Hudson
  • 397
  • 1
  • 12
0

To get the IP address you can use some free web API, there are a lot of them. Here is an example using jQuery:

$.get("https://api.ipify.org/?format=json", function(data) {
    console.info(JSON.stringify(data));
})
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

Or another one, with additional info:

$.get("https://extreme-ip-lookup.com/json/", function(data) {
  console.info(JSON.stringify(data));
})
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
xxxmatko
  • 4,017
  • 2
  • 17
  • 24
0

You can do this on client side using Resonance Nearby. It works only if devices have microphones.

Lolman
  • 46
  • 2