Get Work Status
Read the device's current WorkState.
Prerequisites
- The device is connected
- The device supports
DeviceWorkStateAPI
API Reference
Framework
AIBuds.xcframework
Import
- Swift
- Objective-C
import AIBuds#import <AIBuds/AIBuds-Swift.h>
#import <AIBuds/AIBuds.h>Protocol
- Swift
- Objective-C
/// The protocol for device work state API.
protocol DeviceWorkStateAPI: DeviceAPI {
/// The current working state of the device.
var workState: WorkState { get }
}/// The protocol for device work state API.
@protocol AIBudsDeviceWorkStateAPI <AIBudsDeviceAPI>
/// The current working state of the device.
@property(nonatomic, readonly) enum AIBudsWorkState workState;
@endProperties
| Property | Type | Description |
|---|---|---|
workState | WorkState / AIBudsWorkState | The current working state reported by the device. |
Return Value
workState is a synchronous read-only property. It does not return a composite status model.
Usage Examples
- Swift
- Objective-C
import AIBuds
guard let device = device as? DeviceWorkStateAPI else {
print("Device does not expose a work state")
return
}
let state = device.workState
print("Current work state: \(state.description)")#import <AIBuds/AIBuds-Swift.h>
#import <AIBuds/AIBuds.h>
id<AIBudsDeviceWorkStateAPI> device = (id<AIBudsDeviceWorkStateAPI>)self.device;
if (![device conformsToProtocol:@protocol(AIBudsDeviceWorkStateAPI)]) {
NSLog(@"Device does not expose a work state");
return;
}
NSLog(@"Current work state raw value: %ld", (long)device.workState);Error Handling
There is no completion handler or error result. Handle unsupported protocol conformance and the unknown or reserved enum cases.
Best Practices
- Read the Property Directly: Do not model this API as an asynchronous status request.
- Treat State as Transient: Re-read it when presenting current device activity.
- Handle Every Enum Case: Work states cover connection, call, playback, capture, transfer, streaming, OTA, shutdown, and test activity.
Notes
WorkStateis one enum value; it does not contain battery, charging, wear, or playback fields.- The SDK does not define a
WorkStatusresult model orgetWorkStatusmethod.