What problem does it solve?
AccessorySetupKit removes the need for broad Bluetooth or Wi‑Fi permission prompts by providing a system picker that grants per-accessory access and simplifies secure discovery and authorization of nearby accessories. This prevents unnecessary permission dialogs, reduces privacy exposure, and centralizes the discovery-to-authorization flow so apps can reliably obtain identifiers for post-setup communication.
Core Features & Use Cases
- Privacy-preserving discovery: Present a system-managed picker that grants per-device access without requesting global Bluetooth/Wi‑Fi permissions.
- Descriptor-based matching: Define ASDiscoveryDescriptor rules (service UUIDs, name substrings, company identifiers, SSID/prefixes) to precisely target accessory models.
- Lifecycle and event handling: Activate ASAccessorySession, handle events (.activated, .accessoryAdded, .pickerDidDismiss, .migrationComplete), and coordinate picker presentation tied to explicit user actions.
- Bluetooth and Wi‑Fi workflows: Migrate CoreBluetooth-authorized peripherals with ASMigrationDisplayItem and connect post-setup via CoreBluetooth (using bluetoothIdentifier) or NetworkExtension (using ssid).
- Robust error handling & review checklist: Validate Info.plist keys, avoid initializing CBCentralManager prematurely, enforce descriptor/Info.plist parity, and follow the provided review checklist to prevent crashes.
- Example use case: Add a "Add Accessory" button that activates a session, shows a picker for specific service UUIDs, and connects to the selected accessory using its bluetoothIdentifier.
Quick Start
Activate an ASAccessorySession, create an ASPickerDisplayItem with an ASDiscoveryDescriptor that matches your device, and present the picker in response to a user action to discover and authorize the accessory.