Skip to content

Core Work Mode Get Mode

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

Get Work Mode

Read the device's current WorkMode value.

Prerequisites

  • The device is connected and ready
  • The device supports DeviceWorkModeAPI

API Reference

Framework

AIBuds.xcframework

Import

Swift

import AIBuds

Objective-C

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

Protocol

Swift

/// The protocol for device work mode API.
protocol DeviceWorkModeAPI: DeviceAPI {
    /// The current work mode of the device.
    var workMode: WorkMode { get }
}

Objective-C

/// The protocol for device work mode API.
@protocol AIBudsDeviceWorkModeAPI <AIBudsDeviceAPI>
/// The current work mode of the device.
@property(nonatomic, readonly) enum AIBudsWorkMode workMode;
@end

Properties

Property Type Description
workMode WorkMode / AIBudsWorkMode The current work mode reported by the device.

Return Value

workMode is a synchronous read-only property. It does not use a completion handler.

Usage Examples

Swift

import AIBuds

guard let device = device as? DeviceWorkModeAPI else {
    print("Device does not support work modes")
    return
}

switch device.workMode {
case .normal:
    print("Normal mode")
case .game:
    print("Game mode")
@unknown default:
    print("Unknown work mode")
}

Objective-C

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

id<AIBudsDeviceWorkModeAPI> device = (id<AIBudsDeviceWorkModeAPI>)self.device;
if (![device conformsToProtocol:@protocol(AIBudsDeviceWorkModeAPI)]) {
    NSLog(@"Device does not support work modes");
    return;
}

switch (device.workMode) {
case AIBudsWorkModeNormal:
    NSLog(@"Normal mode");
    break;
case AIBudsWorkModeGame:
    NSLog(@"Game mode");
    break;
default:
    NSLog(@"Unknown work mode");
    break;
}

Error Handling

There is no asynchronous error result. Handle missing protocol conformance and unknown enum values.

Best Practices

  1. Read the Property Directly: Do not create an asynchronous get-work-mode wrapper.
  2. Handle Unknown Values: Include an unknown/default branch for forward compatibility.
  3. Observe Device Updates: Refresh UI when the SDK reports a work-mode change through the device delegate.

Notes

  • The public SDK currently defines normal and game work modes.
  • Changing the mode uses setWorkMode(_:completion:); it is separate from this read-only property.

AIBuds SDK iOS Wiki

Clone this wiki locally