title: Core Bluetooth advertise and scan in the background
body: <p>I have been trying to setup an app to make the device both scan for peripherals and advertise as a peripheral. The goal is for two devices to be woken up in the background when they become near each other via bluetooth discovery. From the Apple Documentation, it seems that you should be able to run BLE in the background (with bluetooth-central and bluetooth-peripheral background modes enabled), and my application works when one device is in the foreground.
  First, I advertise data like so:</p>
  
  <pre><code>NSDictionary *advertisingData = @{CBAdvertisementDataLocalNameKey:@"my-peripheral",
                                CBAdvertisementDataServiceUUIDsKey:@[[CBUUID UUIDWithString:identifier]]};
  
  // Start advertising over BLE
  [peripheralManager startAdvertising:advertisingData]; 
  </code></pre>
  
  <p>I then set the device to scan for data:</p>
  
  <pre><code>NSArray *services = @[[CBUUID UUIDWithString:identifier]];
  
  [centralManager scanForPeripheralsWithServices:services options:nil];
  </code></pre>
  
  <p>However, when both go into the background (device has to be locked), the bluetooth cannot discover and</p>
  
  <pre><code>- (void)centralManager:(CBCentralManager *)central didDiscoverPeripheral:(CBPeripheral *)peripheral advertisementData:(NSDictionary *)advertisementData RSSI:(NSNumber *)RSSI
  </code></pre>
  
  <p>never gets called on either device. How can I fix this?
  Thanks</p>