iOS 18: What's news in CoreBluetooth?
AccessorySetupKit
, introduced in iOS 18, revolutionizes how third-party Bluetooth and Wi-Fi accessories integrate with iOS devices. This framework delivers a seamless setup experience, enhancing convenience for users and expanding capabilities for developers.
While AccessorySetupKit
supports discovery for Bluetooth, Wi-Fi, and Local Network devices, this post will focus specifically on BLE (Bluetooth Low Energy). The setup process for Wi-Fi and Local Network devices follows a similar approach.
Key Features
Below, we’ll explore the key functionalities that make AccessorySetupKit
a major change for accessory management.
- Streamlined Pairing Process: Users can now pair or unpair accessories and toggle Bluetooth directly within the app, eliminating the need to go through system settings. This streamlined approach enhances the user experience and reduces setup time.
- Unified Access Management: Once an accessory is paired, it appears in the new “Accessories” section within the Privacy settings. Here, users can manage permissions and view connected devices, providing a centralized location for accessory management.
- Enhanced Developer Control: Developers can define scanning filters and provide custom images and names for devices, ensuring branded setup experience.
Setup flow
You can find the example project provided by Apple on WWWDC24.
To simulate the accessories, I used CoreBluetooth and defined my Bluetooth profile with two different UUIDs: 1FA2FD8A-17E0-4D3B-AF45-305DA6130E39
and 1FA2FD8A-17E0-4D3B-AF45-305DA6130E38
, then started advertising them.
Next, you need to modify the scanning UUID service in your Info.plist file to match your Bluetooth profiles. This informs the system of the accessory types your app supports.
Apple supports different filter types, such as:
1 | <dict> |
Next, create an ASAccessorySession
. This session is essential for managing the accessory setup process, enabling you to present the accessory picker to users and handle various accessory-related events efficiently.
1 | private var session = ASAccessorySession() |
Then, present the Accessory Picker
. This allows you to display the picker interface, enabling users to easily select and pair their accessories with the app.
1 | let pickerDevice1: ASPickerDisplayItem = { |
The user will now see a list of discovered devices and can select one to begin the pairing process, following the standard flow.
1 | private func handleSessionEvent(event: ASAccessoryEvent) { |
What’s importants?
AccessorySetupKit
streamlines the setup process for users, making it more intuitive and efficient while eliminating the complexity often associated with connecting third-party accessories.
For developers, it provides a standardized integration framework, ensuring consistent user experiences and simplified codebases. By adopting AccessorySetupKit
, developers can deliver a seamless and cohesive experience that aligns third-party accessories with the high standards users associate with Apple products.
Refs
Meet AccessorySetupKit, WWWDC 2024
iOS 18 AccessorySetupKit: Everything BLE Developers Need To Know