質問

I am currently trying to get used to CoreBluetooth and iBeacon on iOS 7. While searching through the API, I noticed that there seem to be three ways of creating and using iBeacons, and I am not 100% sure what the differences are and when to use which. The ways I found are:

  • A location-based approach using CBPeripheralManager and CLLocationManager with a CLBeaconRegion. This has the advantage that it gives me information about the proximity of the devices. But since this is a location-based approach it seems to me that I cannot transfer data with this, which is something I need.

  • Using the Multipeer Connectivity Framework classes, MCNearbyServiceBrowser and MCNearbyServiceAdvertiser. This is very easy to set up, allows me to transfer arbitrary data but I get no information about the proximity of the two devices, which I need.

  • I found an example project by Apple where they use CBCentralManager and CBPeripheral. This allows me to transfer arbitrary data and get limited proximity information (I get the RSSI but no signal accuracy), but seems pretty complex since there are lots of callbacks and I have to take care of stuff like flow control myself.

So I guess my question is: Is there a preferred way? When to use which method? Can they be combined? For example, could I listen to other devices using the location-based approach and then connect to the device when it is nearby using the Multipeer Framework? If so, how could I make sure that I don't accidentally connect to the wrong device?

Thanks!

役に立ちましたか?

解決

iBeacon is for determining location - the idea is that the information about the detected iBeacon is cross-referenced to some other database, say via web services, to determine a physical location - say a branch or store location. While an iBeacon can be another iOS device it may also be a dedicated, but very simple, piece of hardware so there is no ability to transfer data.

The CoreBluetooth framework is about discovery of services and small data transfers. It supports both "well known" service types (such as a heart-rate monitor) and proprietary types. Data ('Characteristics') can be both read and written and a subscription/notify model is used - for example notify when the heart-rate changes.

The Multipeer Connectivity Framework can use Bluetooth or WiFi to advertise and locate services and supports larger data transfers including streaming.

Which technique or techniques you use will depend on what you want to achieve.

他のヒント

You first must decide if you want to use standard iBeacons. If so you cannot use Multipeer Connectivity because standard iBeacons do not support that. Standard iBeacons are transmit only devices that do not allow you to directly do two way data transfer.

You also cannot use CoreLocation with CBCentralManager and CBPeripheral to see iBeacons because the APIs block access to the iBeacon identifiers on iOS. See my answer here.

If you want to use standard iBeacons (allowing use of off the shelf hardware and utilities) you must use CoreLocation APIs. This let's you do ranging easily but not two way data transfer.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top