Domanda

It's not a duplicate of any questions.

I'm creating an app which uses bluetooth to find other users using my app who are near you. With android it's all right. But if I use iOS, is not possible, because as I've read here in stackoverflow, it's not possible to identify a device via bluetooth scan with something which shall be unique, (and if it exists please let me know!!!!) but let me give you an example of what i'm searching:

If two different people are registered in my app (respectively Robin1 and Robin2) and they have the same name in their bluetooth (for example "Robin's iphone"), there is a way to let me know in my app that the first "Robin's iphone" is "Robin1" (his nickname in my app) and the second "Robin's iphone" is "Robin2"? The only thing I need is the bluetooth scanning 'cause my app is based of users really near you and GPS is not precise... not yet.

I hope this example is written good :/

Thank you

È stato utile?

Soluzione

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:

  1. Set the user name to be advertised by the CBAdvertisementDataLocalNameKey in the startAdvertising: call. Though, this is a very brittle solution.
  2. 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.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top