Custom BLE Advertisement on iOS

北城以北 提交于 2021-02-07 12:21:33

问题


I'm hoping to create a BLE advertisement on iOS where I can control the advertisement on a byte level.

One use case would be to mimic an iBeacon advertisement. What is the iBeacon Bluetooth Profile (I want to advertise while my app is in the background which is why I'm not using CoreLocation)

I do not see a way to do this with the Core Bluetooth API. Is this correct? Are there alternatives using private API's or jailbreaking?


回答1:


As the others already pointed out, there is no API on iOS that allows you to do this.

You can advertise as an iBeacon, but only when your app is in the foreground. When in background, the advertisement is removed and therefore cannot be discovered anymore (except for other iOS devices which explicitly scan for that service UUID). Also see the documentation here: Core Bluetooth Background Processing

If you would share your use case and what you want to achieve, maybe there are other ways to realise it.




回答2:


My experience with iOS is that if it is something is not exposed in the API, there is no way around, except jailbreaking. For Bluetooth low energy the API is at GAP/GATT level, and very little at the lower levels (if anything) is exposed. Advertising is a LL (link layer) feature.

To illustrate how restricted the access is: When scanning for BLE devices you will not have access to the advertiser's MAC address iOS. In Android you have it.




回答3:


I do not see a way to do this with the Core Bluetooth API. Is this correct?

Since you have to set Manufacture Specific Data in order to achieve this, if nothing has changed you will experience exactly the same issue that I did. Explained here:

The advertisement key 'Manufacturer Data' is not allowed in CoreBluetooth

It is not possible.



来源:https://stackoverflow.com/questions/39772064/custom-ble-advertisement-on-ios

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