Skip to main content

View Wear Detection Capability

Read whether the device supports wear detection and whether that feature can be configured.

Prerequisites

  • The device is connected and ready.
  • The device conforms to DeviceWearDetectionAPI.

API Reference

Framework

AIBuds.xcframework

Import

Swift
import AIBuds

Protocol

The capability is a property of DeviceWearDetectionAPI.

Swift
/// The protocol for device wear detection API.
protocol DeviceWearDetectionAPI: DeviceAPI {
    /// The wear-detection capabilities supported by the device
    var wearDetectionCapability: WearDetectionCapability { get }
}

Properties

PropertyTypeDescription
wearDetectionCapabilityWearDetectionCapabilityThe capability currently reported by the device.

Supported Values

SwiftObjective-CMeaning
.noneAIBudsWearDetectionCapabilityNoneNot supported.
.supportedNotConfigurableAIBudsWearDetectionCapabilitySupportedNotConfigurableSupported, but not configurable.
.supportedAndConfigurableAIBudsWearDetectionCapabilitySupportedAndConfigurableSupported and configurable.

Usage Examples

Swift
import AIBuds

guard let device = device as? DeviceWearDetectionAPI else {
    print("Wear detection is not exposed by this device")
    return
}

switch device.wearDetectionCapability {
case .none:
    print("Wear detection is not supported")
case .supportedNotConfigurable:
    print("Wear detection is supported but not configurable")
case .supportedAndConfigurable:
    print("Wear detection is supported and configurable")
@unknown default:
    print("Unknown wear-detection capability")
}

Error Handling

This property has no completion handler. Handle failed protocol conformance and unknown future enum values. Do not interpret .none as a transport error; it is a valid capability value.

Best Practices

  1. Read Before Configuring: Check the capability before presenting an enable/disable control.
  2. Preserve All Capability Levels: Do not collapse “not configurable” into “not supported.”
  3. Handle Future Values: Use @unknown default in Swift when switching over the enum.

Notes

  • This API is a synchronous property read, not an asynchronous getWearDetectionSupport method.
  • The SDK Demo uses this property to decide whether configuration controls should be available.