CaseyG
CaseyG

Reputation: 115

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

Upvotes: 7

Views: 3587

Answers (1)

henrik
henrik

Reputation: 1312

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.

Upvotes: 8

Related Questions