I am working on BLE Apps where i need to scan the device in Background mode. While debugging i found that it scan for the device but the discovery of devices is not called and returned. Everything works fine in Foreground Mode.
Why can't my app scan the device while it is running in the background?
Note: I did input the Required background modes 1.App communicates using CoreBluetooth 2.App shares data using CoreBluetooth. Below is the code i called for scan device in foreground
[[LGCentralManager sharedInstance] scanForPeripheralsByInterval:1 completion:^(NSArray *peripherals) {
// If we found any peripherals sending to test
if (peripherals.count > 0) {
for (LGPeripheral *peripheral in peripherals) {
if (peripheral.advertisingData) {
}
}
}];
Output Advertisement data:
Printing description of peripheral->_advertisingData:
{
kCBAdvDataIsConnectable = 1;
kCBAdvDataLocalName = "Device Name";
kCBAdvDataServiceUUIDs = (
"00000000-64B0-5B82-3F51-000000027D2"
);
kCBAdvDataTxPowerLevel = "-2";
}