We are creating a bluetooth hardware device and want to store a unique identifier in the database so that multiple users won't try to connect to the same device. There is an Android and an iOS app.
It is my understanding that in iOS you can't access the MAC Address and the UUID provided is generated on the iOS side. We can add a characteristic providing a UUID, but is there a way to have a consistent identifier on iOS and Android without connecting to the bluetooth device?
If you have control over the hardware and what it advertises then you can include the mac address (or some other unique identifier) as service data or manufacturer-specific data. See https://developer.android.com/reference/android/bluetooth/le/ScanRecord.html on Android L or above. For lower Android versions you have to parse the scan record yourself, which is a bit of a pain.
For iOS see here: https://stackoverflow.com/a/25392156/4248895
For a quick proof of concept on Android you can use SweetBlue which handles the different OS versions for you under the hood. See:
http://idevicesinc.com/sweetblue/docs/api/com/idevicesinc/sweetblue/BleManagerConfig.ScanFilter.ScanEvent.html#serviceData
http://idevicesinc.com/sweetblue/docs/api/com/idevicesinc/sweetblue/BleManagerConfig.ScanFilter.ScanEvent.html#manufacturerData
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With