For one of my projects, I'm currently wanting to build an Ionic application to code once for both iOS and Android platforms. I'm looking for a way to measure the distance between two mobile devices. One device should be placed into a specific location, and the other one should be detected when it enters the range of the first device (or more specifically the location where the first device is).
Device 1 at a specific location will be connected to the internet, same for the device 2 visiting the location.
I've already read a lot of different implementations, but most of the time it requires native code either for Android, or for iOS.
Here are the solutions I've already found :
- Bluetooth: Every cellphone has Bluetooth, so it should not be hard to be able to detect once a phone is close to another one, but it means pairing with another device, and it's not really possible to measure the distance between two devices.
- iBeacons and BLE: We would like to avoid having to buy a lot of beacons at launch. Which means we would like to create a mobile app to act as a beacon, but not possible on Android on a lot of devices. Furthermore, we don't care about micro-locations which means we are not going to use beacons at 100% of their potential.
- GPS: Not really good on a security aspect to assure to both devices that the location is the good one.
- Manual check-in at location: The best way to be sure that device 2 went on the location of device 1 would be to do a manual check at location. But this is kinda frustrating because not innovative at all.
I'm actually running out of ideas. The implementation should be in Javascript to code a quick prototype so options are limited.
I've read a post on StackExchange : Stack, but the problem is that no implementation is described.
In other terms, I want a check-in system to know that device 2 went on the location of device 1. Even with an exchange between an API requesting our servers, how could we be sure that two devices are closed by or at least device 2 went at a specific location?
EDIT & NEWS
To give more options to people who might face the same situation, I got in touch with someone working at Microsoft and on a project called: ThaliProject which you can find on Google which is a PeerToPeer library to communicate between mobile devices. But it's not suited to this problem :
Unfortunately Thali isn't going to solve your problem. :( We depend on Bluetooth 4.2 support on Android (so we can be both a BLE central and peripheral).
Bluetooth also won't work if you need things to work between an Android and iOS device because Apple uses a proprietary variant of Bluetooth that doesn't work.
Now BLE does work between Android and iOS. And while many Android phones can't be peripheral, most of them can be central.
Another possibility that different folks are playing around with is sound. Something like https://developers.google.com/nearby/messages/overview?hl=en. A number of groups have been experimenting with local discovery via ultrasonic communication. Just send the challenge and get the response over ultrasonic and you have proven that devices 1 and 2 are very close to each other.
I found by chance a JavaScript library called: SonicNet.JS to be able to send data and strings by ultrasounds, but I'm actually struggling to make it work on my computer. This might be a solution and avoid interoperability problems.