This is not a question but rather a small bit of documentation on how Accessory Setup Kit actually works. I spent a couple days figuring this out so I thought let's share my findings. The example app is very light and the documentation definitely has room for improvement so here are a couple important notes.
Findings:
- If you're running > iOS 18 and add any property to your Info.plist file you're no longer able to scan for devices by using CBCentralManager.scanForPeriphals.This will no longer return discoverable devices. Below iOS 18 these properties in the Info.plist are ignored by the OS and you can safely use the "legacy" method of connecting to bluetooth devices.
- If you're running > iOS 26 the removeAccessorywill show a prompt to the user. If you're running < 26 you can silently remove the accessory and start each session with a clean state.
- If you create CBCentralManagerbefore you start the ASK session you'll not get thestate = PoweredOn.
- If you have 0 accessories connected to your application CBCentralManagerwill never enter thestate = PoweredOnwhen you create theCBCentralManager. Pre-ASK this would be the trigger for iOS to ask the user permission. This is no longer necessary with ASK.
- If you have have 1 or more accessories authorized to your app this will be returned in the session.accessoriesafter the session has started. This is an important indicator to determine app behavior.
- If you have 1 or more accessories CBCentralManager.scanForPeripheralswill ONLY return previously authorized AND discoverable devices. Use this for when you want to connect to a previously authorized device.
- If you have 1 or more accessories and the CBCentralManager.scanForPeripheralsreturns nothing you can (safely) assume the user attempts to onboard a new device.
So for my application I take the following steps:
- Check for iOS version, if > iOS 18 start ASK session.
- Are there previously authorized devices?
- -- yes: run CBCentralManger.scanForPeripherals
- -- no: show the picker
- Did the scan return any devices?
- -- yes: show UI to select device or connect with first available device in the list
- -- no: show the picker
Feel free to add any of your findings and @Apple please update the documentation!