简体   繁体   中英

Using Core Bluetooth to get Bluetooth LE peripheral advertisements in background

I'm having trouble figuring out how to receive Bluetooth LE peripheral device advertisements while my app is running in the background. That is, when my app is in the background it never reaches the didDiscoverPeripheral() method--where the advertisement lies.. Does anyone know how I need to configure my app such that I can get Bluetooth LE advertisements while my app is in the background? Can this be done with a thread polling while my app is in the background? Note: I want to get advertisements from all BLE devices, not a defined number of BLE devices.

Appreciate the help,

Casey

I am doing this from my app.

in background mode CoreBluetooth is said to be up to 55 times slower than the advertisement interval of the peripheral. To speed it up I programmed the peripheral to advertise every 20ms for the first 30s.

Also you must define "Requires background mode" with "App communicates using CoreBluetooth" in your project Targets -> Info.

It does take a while for the app to find peripherals in the background mode.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM