Skip to main content

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

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.
View official skill

Getting Started

  1. Connect to the Device - Wait until the device is connected and ready.
  2. Check Protocol Conformance - Verify support for DeviceWearDetectionAPI.
  3. Read the Capability - Use wearDetectionCapability to determine whether detection is supported and configurable.
  4. Read the Current State - Use isWearDetectionEnabled and wearStatus.
  5. Configure When Supported - Call setWearDetection(enabled:completion:) only for a configurable device.

Key Concepts

Capability

WearDetectionCapability distinguishes three levels:

ValueMeaning
.noneWear detection is not supported.
.supportedNotConfigurableWear detection is supported, but its enabled state cannot be changed through this API.
.supportedAndConfigurableWear detection is supported and can be enabled or disabled.

State

  • isWearDetectionEnabled reports whether detection is currently enabled.
  • WearStatus reports 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
guard let device = device as? DeviceWearDetectionAPI else {
    print("Device does not support DeviceWearDetectionAPI")
    return
}

Best Practices

  1. Check Capability Before Configuration: Only .supportedAndConfigurable authorizes changing the enabled state.
  2. Use Current Properties: Read the SDK's current snapshots rather than calling invented query methods.
  3. Observe Changes: Use DeviceDelegate callbacks for enabled-state and wear-state changes.
  4. Treat Unknown Explicitly: Keep .unknown distinct 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 DeviceWearDetectionAPI and only presents configuration when the capability is configurable.