Search code examples
iosobjective-cibeacon

iOS / Beacons - How to fire didEnterRegion when turning on Bluetooth?


I have set up an application using ibeacons, and I notice that didEnterRegion is never fired when I turn on Bluetooth while inside the region. It however works fine when I physically enter the region with the Bluetooth on.

When in foreground, I tricked this behavior by calling [self.locationManager requestStateForRegion:self.beaconRegion] in didStartMonitoringForRegion, and checking I was inside.

However, I don't know what to do in background. I understand that the only method that could be fired is didEnterRegion, which would mean that I can't send a notification when just turning on Bluetooth inside a region.

Did someone managed to do that?

thanks


Solution

  • One idea that comes to mind: add bluetooth-central background mode to your app, and implement the CBCentralManager and CBCentralManagerDelegate's centralManagerDidUpdateState. This should wake your app whenever Bluetooth is enabled or disabled, and you can use this time to requestStateForRegion.