iOS BLE - How to keep app active in the background?

怎甘沉沦 提交于 2020-01-01 19:15:18

问题


I am trying to find a clever way to keep a BLE app active in the background on iOS 6, without breaking any of Apple's rules. I plan to use the phone as a peripheral device and another BLE circuit as the central. My app will automatically be opened when a user arrives to a building using geofencing. After that the iPhone will connect to the first BLE central device it sees (the device will be in its white list). The user will then be able to move throughout the building switching to different BLE "nodes".

My question is: What do I need to do in the background when a user is stationary at their desk so that the app does not get suspended due to memory resources?

My idea is based on this solution for a separate problem: There could potentially (not regularly) be 10-50 users in an area with only a few BLE "nodes" and I read at bluetooth.org that I could setup a dynamic connection system, basically rotating connections through all the users.

My idea is to setup a similar dynamic system where the central device (not the iPhone) disconnects the device on regular intervals (30-40 minutes) and then the iPhone will reconnect.

Is this something that some feasible? Is this against the iOS development guidelines? I was unable to find anything explicit about this. I have also asked on the iOS developer forum, but unfortunately it is not as popular as this site.

Thanks in advance!


回答1:


Xcode -> Project target -> Capabilities -> Enable background mode

Check Uses Bluetooth LE Accessories

Capabilities

Also enable the following key in .plist file

Required background modes

App communicates using CoreBluetooth

Plist



来源:https://stackoverflow.com/questions/12944876/ios-ble-how-to-keep-app-active-in-the-background

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