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
- Objective-C
import AIBuds#import <AIBuds/AIBuds-Swift.h>
#import <AIBuds/AIBuds.h>Protocol
The capability is a property of DeviceWearDetectionAPI.
- Swift
- Objective-C
/// The protocol for device wear detection API.
protocol DeviceWearDetectionAPI: DeviceAPI {
/// The wear-detection capabilities supported by the device
var wearDetectionCapability: WearDetectionCapability { get }
}/// The protocol for device wear detection API.
@protocol AIBudsDeviceWearDetectionAPI <AIBudsDeviceAPI>
/// The wear-detection capabilities supported by the device
@property(nonatomic, readonly) enum AIBudsWearDetectionCapability wearDetectionCapability;
@endProperties
| 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
- Objective-C
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")
}#import <AIBuds/AIBuds-Swift.h>
#import <AIBuds/AIBuds.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
- Read Before Configuring: Check the capability before presenting an enable/disable control.
- Preserve All Capability Levels: Do not collapse “not configurable” into “not supported.”
- Handle Future Values: Use
@unknown defaultin Swift when switching over the enum.
Notes
- This API is a synchronous property read, not an asynchronous
getWearDetectionSupportmethod. - The SDK Demo uses this property to decide whether configuration controls should be available.