ding ding - 1 year ago 291
iOS Question

iOS: didDiscoverPeripheral not called in Background mode

I am Working on BLE project, everything works fine when the app in the foreground.It can discover and connect to the peripheral, all the call back method work perfectly.

But the problem is that, when the app in the background mode (I press home button). Only the

delegate method get called.

- (void)centralManagerDidUpdateState:(CBCentralManager *)central{
switch (central.state) {
case CBCentralManagerStatePoweredOn:
[self.cbCentralManager scanForPeripheralsWithServices:nil options:@{ CBCentralManagerScanOptionAllowDuplicatesKey : @YES }];

I use
option, But when the app in the background, the
call back never called. I have edit my plist file with "bluetooth-central" option to support ble central role in background.

Any idea why
method not call when app in the background?

Answer Source

Paulw11 said are right, If your app find the peripherals in the foreground. It will not call the didDiscoverPeripheral for the same peripherals when it enters the background.

For more information about the iOS BLE Behavior in the background mode. You can check this answer What exactly can CoreBluetooth applications do whilst in the background?

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download