WARNING: The advertisement key 'Service Data' is not allowed

我是研究僧i 提交于 2020-07-05 10:26:55

问题


I am developing a BLE peripheral app. By requirement, the advertising packet must contain Service Data field. I have done this in Android, the packet should be like this:

0x16 is Service Data field listed here https://www.bluetooth.com/specifications/assigned-numbers/generic-access-profile/

Same thing, I do it in iOS. I use BluetoothCore framework to implement the bluetooth peripheral.

Below is the attribute I should use to set value for Service Data field:

advertisementData[CBAdvertisementDataServiceDataKey] = <somedata>

However I got a warning:

WARNING: The advertisement key 'Service Data' is not allowed

Can someone let me know why and what is the solution?


回答1:


You cannot specify service data when advertising a peripheral on iOS. You can only specify the service UUID and the service name.

From the documentation:

advertisementData

An optional dictionary containing the data you want to advertise. The possible keys of an advertisementData dictionary are detailed in CBCentralManagerDelegate. That said, only two of the keys are supported for peripheral manager objects: CBAdvertisementDataLocalNameKey and CBAdvertisementDataServiceUUIDsKey.

The solution to your warning is to remove CBAdvertisementDataServiceDataKey from the advertising data dictionary.

I'm afraid there isn't a solution to your requirements on iOS.



来源:https://stackoverflow.com/questions/56315371/warning-the-advertisement-key-service-data-is-not-allowed

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!