CLBeacon - Storing and Extracting Info From PeripheralData NSDictionary?

1.2k views Asked by At

When you start advertising a CLBeacon with peripheral data, can you pass in a NSString or UIImage into this dictionary that you could then have show up when the beacon is discovered?

For example, if I wanted to create write a message to a friend and then when the friend entered the beacon area, could I have the message show up on their phone by storing the message in the NSDictionary and then extracting it? If so, how? If not, is there another way?

Thanks!

2

There are 2 answers

0
Duncan C On

So you are asking if you could add extra information to the beacon advertisement that's sent by a beacon device that a custom application could look for?

The answer is no. The iBeacon protocol is a very short, fixed packet of data. There's no facility for adding extra information to the packets.

You could design and implement your own BLE service that's an alternative to iBeacons and implement it on both the transmitter and the receiver.

You could also use a hybrid approach, where you use standard iBeacon discovery to find beacons, and when you detect a beacon you're interested in, trigger a 2-way BLE conversation with the beacon and ask it for additional information. It's my understanding that some of the BLE devices that are being sold as iBeacons can run custom software that would implement this sort of thing. (Many of these devices have ARM processors in them, the same family of chips that power iOS devices.

0
davidgyoung On

No, you cannot do this. iOS-based iBeacons (like all other standard iBeacons) will only transmit a three-part identifier and a transmitter power calibration value. That's it. You cannot transmit anything else.

Even if you did make a custom Bluetooth LE advertisement that sends additional data besides the standard iBeacon fields, you wouldn't be able to see this data with the standard APIs for seeing iBeacons.

If you want to tie other data to an iBeacon, you have to do it through another channel, by some kind of lookup that matches the data up with the identifiers above. Three common ways to do this:

  1. Hard-code a static lookup table in your app.
  2. Use a Web Service to look up the value based on the iBeacon identifiers.
  3. Fetch the data directly from a (non-standard) iBeacon using a secondary BluetoothLE communication channel.

My company has a web service called ProximityKit that makes it easy to tie data to iBeacons in your app. You log into a web interface to type in key/value pairs to associate with each iBeacon, then the included iOS client library automatically gives you those key/value pairs when the iBeacon is visible.