First off: This is more of a logical question than a code-specific question.
I am trying to create a view similar to the iOS AirDrop view where users can see other users. This means, every user needs to broadcast/advertise their custom username, which can be seen by all other nearby users that scan the area.
I have tried using react-native-ble-plx
, since I read on the Apple developer forum that iPhones can act as BLE (bluetooth low energy) peripherals. (Also, I read that newer Android devices support this as well)
I've tried the following:
import ble, { BleManager, Characteristic } from 'react-native-ble-plx';// ...const bleManager = new BleManager();bleManager.startDeviceScan(null, null, async (e, d) => { if (e) console.log(`BT Error: ${JSON.stringify(e)}`); if (d && d.id && d.isConnectable) { console.log(`Connecting to: ${d.id} ('${d.name}')...`); const device = await d.connect(); const services = await device.services(); console.log('services: ', services.join(', ')); const characteristic = await device.writeCharacteristicWithResponseForService(BLE_SERVICE_UUID, BLE_SERVICE_UUID, '123'); console.log(`Characteristics: ${JSON.stringify(characteristic)}`); }});
But I haven't found a way to broadcast a value which others can read, is that even possible with BLE?
I've also looked into beacons (specifically react-native-beacons-manager), but I'm not sure if that is what I want since an Android/iOS phone is not a 'beacon'..
So my question is: Are there technologies/libraries that allow broadcasting of a message (my custom username) which others can see? Ideally I want to communicate between them, like exchanging a token, but that's not a requirement.
I'd appreciate any help or pointings into the right direction here, thanks!