How can we advertise custom data through our iOS app using Bluetooth Low Energy advertisement

How can we advertise custom data through our iOS app using Bluetooth Low Energy advertisement?

Answered by Engineer in 826530022

You can only advertise data appropriate for the following Advertising Keys through an app.

Also, keep in mind these will only be readable when your app is running in the foreground. Otherwise, all this data will get hashed with other advertising processes and can only be decoded by another app running on an Apple device in the foreground.

Keep in mind that an iOS device is not a dedicated Bluetooth peripheral, and advertising for apps is done on a best effort basis. As explained at startAdvertising(_:)

Core Bluetooth advertises data on a “best effort” basis, due to limited space and because there may be multiple apps advertising simultaneously. While in the foreground, your app can use up to 28 bytes of space in the initial advertisement data for any combination of the supported advertising data keys. If no this space remains, there’s an additional 10 bytes of space in the scan response, usable only for the local name (represented by the value of the CBAdvertisementDataLocalNameKey key). Note that these sizes don’t include the 2 bytes of header information required for each new data type.

Any service UUIDs contained in the value of the CBAdvertisementDataServiceUUIDsKey key that don’t fit in the allotted space go to a special “overflow” area. These services are discoverable only by an iOS device explicitly scanning for them.

While your app is in the background, the local name isn’t advertised and all service UUIDs are in the overflow area.


Argun Tekant /  DTS Engineer / Core Technologies

You can only advertise data appropriate for the following Advertising Keys through an app.

Also, keep in mind these will only be readable when your app is running in the foreground. Otherwise, all this data will get hashed with other advertising processes and can only be decoded by another app running on an Apple device in the foreground.

Keep in mind that an iOS device is not a dedicated Bluetooth peripheral, and advertising for apps is done on a best effort basis. As explained at startAdvertising(_:)

Core Bluetooth advertises data on a “best effort” basis, due to limited space and because there may be multiple apps advertising simultaneously. While in the foreground, your app can use up to 28 bytes of space in the initial advertisement data for any combination of the supported advertising data keys. If no this space remains, there’s an additional 10 bytes of space in the scan response, usable only for the local name (represented by the value of the CBAdvertisementDataLocalNameKey key). Note that these sizes don’t include the 2 bytes of header information required for each new data type.

Any service UUIDs contained in the value of the CBAdvertisementDataServiceUUIDsKey key that don’t fit in the allotted space go to a special “overflow” area. These services are discoverable only by an iOS device explicitly scanning for them.

While your app is in the background, the local name isn’t advertised and all service UUIDs are in the overflow area.


Argun Tekant /  DTS Engineer / Core Technologies

The peripheral manager only supports two advertisement keys: CBAdvertisementDataLocalNameKey and CBAdvertisementDataServiceUUIDsKey. Is there any way to send 16-byte custom data other than using CBAdvertisementDataLocalNameKey?

How can we advertise custom data through our iOS app using Bluetooth Low Energy advertisement
 
 
Q