Distance between two mobile devices using an Ionic application

For one of my project I’m currently wanting to build a Ionic application to code once for both iOS and Android platforms. I’m looking for a way to measure two mobile devices. One device should be place 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 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 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 like 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 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 limitated.

I’ve read a post on StackExchange : Stack, but the problem is that no implementation are described.

In other terms, I want a check in system to know that device 2 went on 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 ?