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