The Apple documentation is I believe correct although in places it isn't as explicit as I would prefer. This short article aims to explain what you can and cannot do in the background and the behaviour you will see. This information is relevant for iOS 7. [Update:
If iOS 8 is different I will try to revise this post at a later date. iOS 8 behaviour appears the same in my initial testing and I couldn't find any significant changes documented and there was no CoreBluetooth talk at WWDC 14.] If you think anything is inaccurate please let me know I don't want to mislead anyone and my testing hasn't been extensive.
Not Quite Enough for Peer to Peer Applications
My summary of the situation is that you can't do quite enough to support peer to peer in a viable way unless you have an app that you expect to be run on a regular basis anyway because the background modes (except for iBeacon detection) do not persist through a reboot of the phone or a flat battery. This means that the user will fall off your peer to peer application framework.
iBeacons can awake apps that have not been running since a reboot but iOS devices can only themselves perform as iBeacons in the foreground.
What Devices Support Bluetooth Low Energy (and background operation)?
What Can iOS Devices Do in the Background (Bluetooth)?
- Be notified of iBeacons matching a particular UUID in the local vicinity.
- Advertise as peripheral device by UUID.
- Act as central manager and scan for peripheral devices by UUID.
(2) and (3) on the other hand survive being put into the background and if the App has been terminated due to memory pressure and is no longer running in the background the App will be resumed for a short period to process the connection. However if the App is closed by flicking up from the app switcher or if the phone has been shutdown, run out of battery or rebooted then the background bluetooth services will not be resumed so your app will never be alerted.
Can't the iOS device be an iBeacon?
Only while the app is in the foreground, I don't believe it is possible to support this in the background at all.
Why Would I Want to Do Peer to Peer in the Background Anyway?
Well there are apps like AroundThen which try to use Bluetooth Low Energy to enable you link to people you have met (been in close proximity) to your online social networks. This seems a reasonable case and there are probably more that I haven't considered either
Heavily Used App
If you are Facebook you may be able to rely on sufficient usage of your application to have a good coverage for a peer to peer Bluetooth service to be effective. Enough people will run your app anyway within a few hours of rebooting the phone that you can still get some super local contact exchange happening.
Rely on Android iBeacons...
I haven't tested this approach but if Android devices can perform as iBeacons in the background (which I haven't tried and may not be possible) you could register to be awoken on contact with an iBeacon and then start to advertising and scanning as a BLE peripheral and central manager. I haven't tried doing this triggered by the iBeacon either.
This approach if it works could allow the population of Android users of an app to keep the iOS users within the peer to peer group. You still need a critical mass of devices (particularly Android ones) there for the app to really work.