11
votes

I am running core bluetooth in the background to scan for a device. It works fine, and pretty much stops when i QUIT the app manually. Apple docs state that the app can be woken up by the peripheral sometimes, and this may bring it from suspended state for about 10 seconds or so, do some operation and then go back to suspended.

Source: https://developer.apple.com/library/IOs/documentation/NetworkingInternetWeb/Conceptual/CoreBluetooth_concepts/CoreBluetoothBackgroundProcessingForIOSApps/PerformingTasksWhileYourAppIsInTheBackground.html

For this to work, does the peripheral need to have already "connected" in order to wake up the app? Or can any new (undiscovered) peripheral wake up the app?

1

1 Answers

6
votes

Your app will only be woken up for peripheral events (connection/disconnection etc). However, if a user chooses to force kill your app (swiping up in iOS 7), your app will not wake up for these events. The iOS system will remove you until the user manually opens your app once more.

In order to subscribe to these peripheral wake up events, you need to pass in an NSDictionary with the appropriate restoration options when initing your manager. The exact details are provided in the link you put in your question above.

And as for your last question: NO, scanning and then finding some peripheral will not wake your app up in the background. It is only applicable for pre-specified peripherals.