Skip to main content

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

Protocol

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

Properties

PropertyTypeDescription
workModeWorkMode / AIBudsWorkModeThe 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")
}

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.