Search code examples
ioscore-locationcore-bluetoothibeacon

Get raw byte data array from ibeacon in ios app


My iBeacon, in addition to the standard UUID, Major, Minor, RSSI data, contains additional information about the battery level, which is located in a set of raw data bytes.

On Android, I can easily get this value using the altbeacon library, which ultimately receives an object that includes an array of LastPocketRawDataBytes bytes.

When detecting a beacon in an iOS application using CoreLocation, I get a CLBeacon object, which does not include an array of raw data. In addition, when detecting the same beacon using CoreBluetooth, its advertising data does not include any Manufacturer Data array.

How can I get an array of raw data bytes from iBeacon?

P.S. I found a similar question regarding a similar problem, but in this case you will have to interfere with the beacon (if this is the only solution, then I am ready to consider various options for this)


Solution

  • Unfortunately, iOS blocks reading the raw bytes of a Bluetooth advertisement in the iBeacon format.

    • The CoreLocation API allows you to detect iBeacon advertisements, but fields are limited. You can only read the iBeacon Proximity UUID, Major, and Minor identifier. This API allows no access to any other fields.

    • The CoreBluetooth API does not allow you to detect iBeacon advertisements at all. Apple has implemented filter in software that blocks reading iBeacon with this API. So while the API does allow access to all fields inside Bluetooth advertisements in general, iBeacon advertisements are an exception to this ability. See my blog post here about this iOS restriction.

    One possible alternative may be to use a different beacon format. Some beacon manufacturers allow you to configure a beacon to advertise different formats and sometimes two formats at once. If you can configure the beacon to advertise AltBeacon (instead of or in addition to iBeacon), then you can use the iOS CoreBluetooth APIs to read these additional fields. One caveat on this technique: Your iOS app must be in the foreground to read these fields.