I am doing some tests about waking up an app after it was killed or after a phone restart, while waiting to discover iBeacons.
According to Apple documentation:
The region monitoring service delivers events normally while an app is running in the foreground or background. (You can use this service for both geographic and beacon regions.) For a terminated iOS app, this service relaunches the app to deliver events. Use of this service requires “Always” authorization from the user.
I use:
[CLLocationManager startMonitoringForRegion:]
to search for iBeaconslocationManager:didEnterRegion:
andlocationManager:didExitRegion:
delegates- I ask to
CLBeaconRegion
to be notified fornotifyOnEntry
andnotifyOnExit
- Background permissions for execution is correctly set for Location
So far it works quite well, the app is correctly restarted when I kill the app but enter an iBeacon region. It also works when I restart the phone, so my app configuration seems ok.
However, if I let my phone with its screen off just after a restart instead of using it, the phone can react really slowly (after some hours) to a beacon region change. If I actively switch on the screen and unlock the phone, it seems the phone will react more quickly to iBeacons.
Here is what I've observed (iOS 9.3) immediately after a reboot:
- on the lock screen, the bluetooth icon is missing, even if the bluetooth icon is well activated after I unlock the phone; it is worth to note that if I trigger some beacon region change, the app will not react immediately after a reboot
- after having unlocked the phone once, when I sometimes switch the screen on without unlocking the phone, it seems that while the bluetooth icon does not appear, any beacon region change will not trigger anything
- at one point in the time, a bluetooth icon starts to appear on the lock screen; it seems the phone is then reactive to a beacon region change
Is there some explanations on the way Bluetooth is managed at restart? Can it be predicted?
I need to be able to explain why region monitoring on iBeacon is not so reactive after a phone restart. I wonder if the phone waits a kind of "significant location change" event to correctly switch on its Bluetooth device.