Wear Detection Overview
Wear Detection exposes the device's capability, enabled state, and current left/right wear state. Devices that report a configurable capability can also enable or disable detection through the SDK.
Available Features
View Wear Detection Capability
Read the wear-detection capability reported by the device
View Wear Detection State
Read the enabled state and current wear state reported by the device
Set Wear Detection
Enable or disable wear detection on a configurable device
Implement with AI Assistance
Build with AI
Implement this workflow with AI
Use the official Manage AIBuds Wear Detection skill to adapt this workflow to your app.
Read and follow https://docs-aibuds.github.io/skills/manage-aibuds-wear-detection. Use it to implement Manage AIBuds Wear Detection in this iOS project and verify the result.Getting Started
- Connect to the Device - Wait until the device is connected and ready.
- Check Protocol Conformance - Verify support for
DeviceWearDetectionAPI. - Read the Capability - Use
wearDetectionCapabilityto determine whether detection is supported and configurable. - Read the Current State - Use
isWearDetectionEnabledandwearStatus. - Configure When Supported - Call
setWearDetection(enabled:completion:)only for a configurable device.
Key Concepts
Capability
WearDetectionCapability distinguishes three levels:
| Value | Meaning |
|---|---|
.none | Wear detection is not supported. |
.supportedNotConfigurable | Wear detection is supported, but its enabled state cannot be changed through this API. |
.supportedAndConfigurable | Wear detection is supported and can be enabled or disabled. |
State
isWearDetectionEnabledreports whether detection is currently enabled.WearStatusreports unknown, not wearing, left-only, right-only, or both-ear state.- Capability, enabled state, and wear state are separate values; do not infer one from another.
Protocol Reference
Wear Detection is accessed through DeviceWearDetectionAPI:
- Swift
- Objective-C
guard let device = device as? DeviceWearDetectionAPI else {
print("Device does not support DeviceWearDetectionAPI")
return
}id<AIBudsDeviceWearDetectionAPI> device = (id<AIBudsDeviceWearDetectionAPI>)self.device;
if (![device conformsToProtocol:@protocol(AIBudsDeviceWearDetectionAPI)]) {
NSLog(@"Device does not support AIBudsDeviceWearDetectionAPI");
return;
}Best Practices
- Check Capability Before Configuration: Only
.supportedAndConfigurableauthorizes changing the enabled state. - Use Current Properties: Read the SDK's current snapshots rather than calling invented query methods.
- Observe Changes: Use
DeviceDelegatecallbacks for enabled-state and wear-state changes. - Treat Unknown Explicitly: Keep
.unknowndistinct from.notWearing.
Notes
- An enum case existing in the SDK does not guarantee that every device supports that capability.
- The SDK does not promise automatic playback behavior when wear state changes; application behavior should be based on product requirements.
- The SDK Demo reads capability and enabled state from
DeviceWearDetectionAPIand only presents configuration when the capability is configurable.