Background Scan for Bluetooth Devices (inc. Apple AirPods) with known Peripheral UUID


In my iOS app, When I scan for Bluetooth devices, I see Peripheral UUID and other data from each nearby device, like below:

(uuid: 58B95943-A57E-F818-D3CC-9F8122C64D88, name: "iPad Pro"), advertisementPacket: ["kCBAdvDataRxSecondaryPHY": 0, "kCBAdvDataRxPrimaryPHY": 1, "kCBAdvDataIsConnectable": 1, "kCBAdvDataTimestamp": 612132622.292843, "kCBAdvDataTxPowerLevel": 12], rssi: -37

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.

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.

I’ve tried several approaches:

  1. 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.

  2. I know I can scan for devices with known Service IDs like this:
    scanForPeripherals(withServices serviceUUIDs: [CBUUID(string: GATT ServiceCode]?, options...
    but I tried every single Assignment number on Bluetooth GATT Services Specifications website, and none of them seem to find Apple Airpods or other Apple devices.

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.

Source: Ios

Categorised as bluetooth, core-bluetooth, ios, swift


You are confusing device identifiers with service identifiers.
The UUID you shown for the iPad Pro is an identifier that has been assigned by Core Bluetooth on your device for that device. Every other iOS device in the world will receive a different identifier for that iPad.

Devices can advertise well known GATT services, such as battery information, device information or “private” services. These services are also identified by a UUID. These are the UUIDs that you scan for. E.g. your app could scan for devices advertising a “heart rate monitor” service.

To see specific services in the advertisement you need an app running in the device acting as a peripheral and advertising a service.

If your intention is to understand when this particular device is nearby then the approach would be to try and maintain a connection to it.

If you connect to the device then you will get a delegate callback when it disconnects (e.g. it goes out of range). You can then immediately issue another connect. This connection will be pending until the device is back in range. iOS will then reconnect and you will get another delegate callback.

Ms. Natalie DuBuque

Leave a Reply

Your email address will not be published. Required fields are marked *

Still Have Questions?

Our dedicated development team is here for you!

We can help you find answers to your question for as low as 5$.

Contact Us