Strategies for identifying devices have been widely discussed on the bluetooth-dev mailing list and in many Stack Overflow questions as well. For example, check out this discussion: http://lists.apple.com/archives/bluetooth-dev/2013/Nov/msg00071.html
For simplicity here are two options:
- Set the user name to be advertised by the CBAdvertisementDataLocalNameKey in the
startAdvertising:
call. Though, this is a very brittle solution. - More robust is to connect to the discovered peripheral and read a characteristic that your application includes to expose the user identifier.
Note that you cannot rely on using the CBPeripheral.identifier
for identification as it is going to be a different random value on every device that discovers the peripheral. Also note that if you plan on using backgrounded operation, then that will require special care as many restrictions kick in when the app goes to background.