Search code examples
iosbluetoothbluetooth-lowenergycore-bluetoothibeacon

Using generic BLE beacons with iOS?


I'm looking to create a BLE Beacon which does not follow Apples iBeacon specification. The reason being that the "beacon" will be an arduino device which the app should also be able to communicate to to instruct it to do things. Is this supported on iOS? I've heard rumours of iOS 8 locking down on generic device advertising via Bluetooth.

Thanks in advance.


Solution

  • Yes, you can do this using the CoreBluetooth APIs, but there are a few restrictions depending on what type of Bluetooth LE advertisement you use.

    1. Manufacturer Advertisement

    You can read all the bytes of the manufacturer advertisement (up to 24 bytes) using CoreBluetooth, but only when an app is in the foreground. In the background, you will get no callbacks. This is often paired with a second iBeacon advertisement that wakes the app up in the background on iOS. For an example of this type of advertisement, see the AltBeacon specification.

    2. GATT Service Advertisement

    A GATT service advertisement detection will be sent to an app by CoreBluetooth even when the app is in the background, provided that the app is specifically looking for the GATT service UUID of the beacon. The disadvantage of this approach is that the data payload is generally limited to only 18 bytes after the 2-byte service UUID.

    Other Details

    In the case of both advertisement types, you can connect to the device using GATT, and read and write data. Note, however, that once you connect the device will generally stop advertising as a beacon.

    Both of the above work as described with iOS 8. It's hard to predict the future, but it seems unlikely that Apple will lock down on the above two use cases as they are widely used for Bluetooth LE applications aside from Beacons.

    You can see the basic steps to read these advertisements in this blog post. While the post is specifically about how Apple filters out iBeacon advertisements, if you make your own custom manufacturer advertisement, it will allow you to read the bytes as described in the post.

    For the sake of completeness, both of the advertisement types above can be picked up by Android devices both in the foreground and the background.