-
Notifications
You must be signed in to change notification settings - Fork 0
Core Wear Detection Get Switch Status
Mr.P edited this page Aug 29, 2026
·
2 revisions
Read whether wear detection is enabled and whether neither, one, or both earbuds are currently worn.
- The device is connected and ready.
- The device conforms to
DeviceWearDetectionAPI.
AIBuds.xcframework
import AIBuds#import <AIBuds/AIBuds-Swift.h>
#import <AIBuds/AIBuds.h>/// The protocol for device wear detection API.
protocol DeviceWearDetectionAPI: DeviceAPI {
/// Indicates whether wear detection is currently enabled
var isWearDetectionEnabled: Bool { get }
/// The current wear status of the device.
var wearStatus: WearStatus { get }
}/// The protocol for device wear detection API.
@protocol AIBudsDeviceWearDetectionAPI <AIBudsDeviceAPI>
/// Indicates whether wear detection is currently enabled
@property(nonatomic, readonly) BOOL isWearDetectionEnabled;
/// The current wear status of the device.
@property(nonatomic, readonly) enum AIBudsWearStatus wearStatus;
@end| Property | Type | Description |
|---|---|---|
isWearDetectionEnabled |
Bool / BOOL
|
Whether wear detection is currently enabled. |
wearStatus |
WearStatus |
The current left/right wear state. |
| Swift | Objective-C | Meaning |
|---|---|---|
.unknown |
AIBudsWearStatusUnknown |
The wear state is unknown. |
.notWearing |
AIBudsWearStatusNotWearing |
Neither side is worn. |
.leftWearing |
AIBudsWearStatusLeftWearing |
Only the left side is worn. |
.rightWearing |
AIBudsWearStatusRightWearing |
Only the right side is worn. |
.bothWearing |
AIBudsWearStatusBothWearing |
Both sides are worn. |
import AIBuds
guard let device = device as? DeviceWearDetectionAPI else {
print("Device does not support wear detection")
return
}
print("Wear detection enabled: \(device.isWearDetectionEnabled)")
switch device.wearStatus {
case .unknown:
print("Wear state is unknown")
case .notWearing:
print("Neither side is worn")
case .leftWearing:
print("Only the left side is worn")
case .rightWearing:
print("Only the right side is worn")
case .bothWearing:
print("Both sides are worn")
@unknown default:
print("Unsupported wear-state value")
}#import <AIBuds/AIBuds-Swift.h>
#import <AIBuds/AIBuds.h>
id<AIBudsDeviceWearDetectionAPI> device = (id<AIBudsDeviceWearDetectionAPI>)self.device;
if ([device conformsToProtocol:@protocol(AIBudsDeviceWearDetectionAPI)]) {
NSLog(@"Wear detection enabled: %@", device.isWearDetectionEnabled ? @"YES" : @"NO");
NSLog(@"Wear status raw value: %ld", (long)device.wearStatus);
}These are synchronous snapshot properties and do not return errors. Handle unsupported protocol conformance and .unknown explicitly. A current state may change after it is read.
-
Keep Enabled and Wear State Separate:
falseand.notWearingdescribe different concepts. -
Observe Updates: Implement
didWearDetectionEnabledChangedanddidWearStatusChangedwhen the UI must remain current. - Update UI on the Main Thread: Dispatch delegate-driven UI changes to the main queue when required.
- The SDK exposes properties rather than
getWearDetectionSwitchStatusorResult-based query methods. -
.unknownmust not be displayed as “not wearing.”
AIBuds SDK documentation · Full documentation · API Reference
- Introduction
- Getting Started
- Core Concepts
-
Core Features
- Basic Features
- Device Info
- Find Device
- Physical Operations
- Work Mode
- Work Status
- Wear Detection
- Volume Control
- Music Control
- TWS
- Equalizer
- ANC
- Audio
- Camera
- Remote Camera
- File Import
- Teleprompter
- Segment Navigation
- Live Streaming
- Device Applications
- OTA
- Camera OTA
- Service Auth
- AI Services
- Voice Assistant
- Logging
- Advanced Topics
- Releases
- Troubleshooting