title: Background Scan for Bluetooth Devices (inc. Apple AirPods) with known Peripheral UUID
body: <p>In my iOS app, When I scan for Bluetooth devices, I see Peripheral UUID and other data from each nearby device, like below:</p>
  
  <pre><code>(uuid: 58B95943-A57E-F818-D3CC-9F8122C64D88, name: "iPad Pro"), advertisementPacket: ["kCBAdvDataRxSecondaryPHY": 0, "kCBAdvDataRxPrimaryPHY": 1, "kCBAdvDataIsConnectable": 1, "kCBAdvDataTimestamp": 612132622.292843, "kCBAdvDataTxPowerLevel": 12], rssi: -37
  </code></pre>
  
  <p><strong>I then wish to continue scanning for a single device with specific UUID in the background (when the app is closed) and be notified when the app is near or connectable.</strong></p>
  
  <p>Please note that many of the devices (including Apple iPad etc) do not have a UUID in the advertisement packet. They have a UUID in Peripheral info only.</p>
  
  <p>I've tried several approaches:</p>
  
  <ol>
  <li><p>There is a Connect method where you leave a connect to request for Bluetooth device waiting in the background and callback lets you know when the device connects but this does not work for Apple AirPods which never connect.</p></li>
  <li><p>I know I can scan for devices with known Service IDs like this:
  <code>scanForPeripherals(withServices serviceUUIDs: [CBUUID(string: GATT ServiceCode]?, options...</code>
  but I tried every single Assignment number on <a href="https://www.bluetooth.com/specifications/gatt/services/" rel="nofollow noreferrer">Bluetooth GATT Services Specifications website</a>, and none of them seem to find Apple Airpods or other Apple devices.</p></li>
  </ol>
  
  <p>I have seen other iOS apps work in the background for devices including Apple AirPods, so there has to be a way to achieve this.</p>