How can I attached an accessory to the iphone?
Asked on 07/30/2024
1 search
To attach an accessory to an iPhone, you can use the new AccessorySetupKit introduced in iOS 18. Here are the steps to follow:
-
Discovery and Authorization:
- Use the
ASAccessorySession
to present the accessory picker. - Provide an array of
ASPickerDisplayItem
objects, which define the name, image, and discovery descriptor for the accessory. - Call
showPicker
on theASAccessorySession
to begin the discovery and authorization process.
- Use the
-
Pairing:
- The accessory picker will appear with any nearby accessories that your app wants to pair with.
- With just one tap, the accessory is securely paired with your app, granting both Bluetooth and Wi-Fi access if supported.
-
Event Handling:
- When the setup finishes, your app will receive an
ASAccessoryEvent
via the session object. - This event contains important information about the newly added accessory for your app to interact with it.
- When the setup finishes, your app will receive an
-
Managing Accessories:
- The
ASAccessory
class represents a physical accessory and includes properties like authorization state, display name, discovery descriptor, and networking interfaces. - You can manage accessories through the new accessory page in Bluetooth and Wi-Fi settings, where users can modify the accessory name, toggle access, or remove it from the system.
- The
For a detailed walkthrough, you can refer to the session Meet AccessorySetupKit (00:01:03).
Relevant Sessions
- Meet AccessorySetupKit
- What’s new in privacy (Accessory Setup Kit picker)

What’s new in privacy
At Apple, we believe privacy is a fundamental human right. Learn about new and improved permission flows and other features that manage data in a privacy-preserving way, so that you can focus on creating great app experiences.

Meet AccessorySetupKit
Elevate your accessory setup experience with AccessorySetupKit. Display a beautiful pairing dialog with an image of your Bluetooth or Wi-Fi accessory — no trip to the Settings app required. Discover how to improve privacy by pairing only your app with an accessory. And learn how you can migrate existing accessories so they can be managed by AccessorySetupKit.