Does anyone know if core BLE continues to run in the background after a user force quits the app in iOS 7.1? Or does just iBeacon continue to run? I know that neither will continue to broadcast on force quit, but will both continue to scan?
EDIT: I've attempted to test the current implementation I've had and it doesn't appear to be running in the background after force quit. What I've heard so far from other sources is that it does but it doesn't appear to be running for me with the standard CoreBluetooth implementation.
For CoreBluetooth (CBCentralManager and CBPeripheralManager), the following rules apply:
- If the user closes the app manually using the app switcher, the BLE part of your app also gets killed.
- If the user does not close the app manually, you can use the
bluetooth-central and bluetooth-peripheral background modes to get relevant callbacks while your app is backgrounded. However, iOS may still kill your app under memory pressure or for whatever reason, in which cases the BLE part is also gone.
- To keep the BLE part alive, you can use restore identifiers when instantiating CBCentralManager and CBPeripheralManager. Managers with a restore identifier are kept alive even after iOS killed your app, and if an interesting BLE event occurs), your app will be launched into background and you will be passed the state of the managers when the app got killed for restoration.
- The main queue is suspended during background execution - make sure to configure the managers in a way that events are not dispatched on the main queue.
- If the user closes the app manually using the app switcher, restoration is forfeited and the BLE part of your app won't stay alive.
- To test restoration, you need to resolve to using tools like BackgroundKill. Note that the Xcode debugger may keep your app alive, so make sure to disconnect the debugger first (which will kill the app), then launch your app, then open BackgroundKill and examine the Console output in the Xcode Organizer window.