Skip to content

Core Wear Detection Get Support

Mr.P edited this page Aug 25, 2026 · 2 revisions

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

Objective-C

#import <AIBuds/AIBuds.h>
#import <AIBuds/AIBuds-Swift.h>

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 }
}

Objective-C

/// The protocol for device wear detection API.
@protocol AIBudsDeviceWearDetectionAPI <AIBudsDeviceAPI>
    /// The wear-detection capabilities supported by the device
    @property (nonatomic, readonly) enum AIBudsWearDetectionCapability wearDetectionCapability;
@end

Properties

Property Type Description
wearDetectionCapability WearDetectionCapability The capability currently reported by the device.

Supported Values

Swift Objective-C Meaning
.none AIBudsWearDetectionCapabilityNone Not supported.
.supportedNotConfigurable AIBudsWearDetectionCapabilitySupportedNotConfigurable Supported, but not configurable.
.supportedAndConfigurable AIBudsWearDetectionCapabilitySupportedAndConfigurable Supported 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")
}

Objective-C

#import <AIBuds/AIBuds.h>
#import <AIBuds/AIBuds-Swift.h>

id<AIBudsDeviceWearDetectionAPI> device =
    (id<AIBudsDeviceWearDetectionAPI>)self.device;
if (![device conformsToProtocol:@protocol(AIBudsDeviceWearDetectionAPI)]) {
    NSLog(@"Wear detection is not exposed by this device");
    return;
}

switch (device.wearDetectionCapability) {
    case AIBudsWearDetectionCapabilityNone:
        NSLog(@"Wear detection is not supported");
        break;
    case AIBudsWearDetectionCapabilitySupportedNotConfigurable:
        NSLog(@"Wear detection is supported but not configurable");
        break;
    case AIBudsWearDetectionCapabilitySupportedAndConfigurable:
        NSLog(@"Wear detection is supported and configurable");
        break;
}

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.

AIBuds SDK iOS Wiki

Clone this wiki locally