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 municate 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 . A number of groups have been experimenting with local discovery via ultrasonic munication. 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 puter. This might be a solution and avoid interoperability problems.
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 municate 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./nearby/messages/overview?hl=en. A number of groups have been experimenting with local discovery via ultrasonic munication. 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 puter. This might be a solution and avoid interoperability problems.
Share Improve this question edited Jul 23, 2024 at 2:21 Sathyapriya Muthukrishnan 3872 silver badges13 bronze badges asked Mar 14, 2017 at 22:32 ZeroZero 4531 gold badge11 silver badges23 bronze badges 9- 1 Have you tried using the Google Maps API? link I have personally used it previously to do something similar (also using Firebase to store the device's coordinates). – Gabriel Lovetro Commented Mar 15, 2017 at 14:04
- 1 No I didn't, but I already thought about that solution. The problem is that I supposed it's based on the GPS coordinates of the users ? Which means it can easily be hacked with a faker ? link – Zero Commented Mar 15, 2017 at 16:44
- Well, there certainly is some security concerns... Unfortunately I cannot help you with that (although the question you linked to should be a good reference for such). – Gabriel Lovetro Commented Mar 16, 2017 at 11:08
- 1 I'm trying since yesterday night to be able to instal everything and test their demo app which is : video. I could be able to make two apps municating eachothers. Maybe I can even get a range between thoose devices who knows. Cordoga plugin so easy to integrate with Ionic I guess. Their is also an authentication between apps which is showed in the video. I'll try to test the app and see how it works and I'll try to keep the subject up to date to make at least a feedback. – Zero Commented Mar 17, 2017 at 18:50
- 1 After few days of rearches I got two different answers : p2pkit : paying solutions, but also nearby : Google nearby which is free, but no integration with Cordova / Ionic. – Zero Commented Mar 21, 2017 at 16:06
2 Answers
Reset to default 0You may use the Bluetooth Low Energy plugin for Cordova (https://github./evothings/cordova-ble). It is mainly working for Android and iOS.
Of course the devices should support BLE but it is the case of numerous new smartphones.
You can start by scanning around you with evothings.ble.startScan(success, error)
and then use the RSSI
and txPower
values to get the distance between devices.
how about Time of Fly from wifi device? Basically, the app on device A needs to send a signal round. Device B picks it up and return a signal with a signature. Device A receives it and calculates the distance based on fly of time.
Or how about using here's API? https://indoor.here./#/. The idea is gps + high precision map. I know you thought about gps already. but hd map gives you a way to validate the gps info the device receive so as to address your security concern.