-
Notifications
You must be signed in to change notification settings - Fork 0
Voice Assistant Get Offline Mode
Mr.P edited this page Aug 29, 2026
·
2 revisions
Read the active on-device voice-assistant mode and request a mode supported by the device capability.
- The device is connected and conforms to
OnDeviceVoiceAssistantAPI. -
onDeviceVoiceAssistantCapabilityis not.none. - The target mode is compatible with the reported capability and is not
.unknown.
AIBuds.xcframework
/// The protocol for the on-device voice assistant API.
protocol OnDeviceVoiceAssistantAPI: DeviceAPI {
/// The current mode of the on-device voice assistant.
var onDeviceVoiceAssistantMode: OnDeviceVoiceAssistantMode { get }
/// Sets the mode of the on-device voice assistant.
/// - Parameters:
/// - mode: The desired mode to set.
/// - completion: Called when the operation completes.
/// - success: `true` when the operation succeeds.
/// - error: Error details on failure; otherwise `nil`.
func setOnDeviceVoiceAssistantMode(_ mode: OnDeviceVoiceAssistantMode,
completion: AIBudsCompletionHandler?)
}/// The protocol for the on-device voice assistant API.
@protocol AIBudsOnDeviceVoiceAssistantAPI <AIBudsDeviceAPI>
/// The current mode of the on-device voice assistant.
@property(nonatomic, readonly) AIBudsOnDeviceVoiceAssistantMode onDeviceVoiceAssistantMode;
/// Sets the mode of the on-device voice assistant.
/// - Parameters:
/// - mode: The desired mode to set.
/// - completion: Called when the operation completes.
/// - success: `YES` when the operation succeeds.
/// - error: Error details on failure; otherwise `nil`.
- (void)setOnDeviceVoiceAssistantMode:(enum AIBudsOnDeviceVoiceAssistantMode)mode
completion:(AIBudsCompletionHandler _Nullable)completion;
@endSee onDeviceVoiceAssistantMode, setOnDeviceVoiceAssistantMode, and OnDeviceVoiceAssistantMode.
| Capability | Modes to present |
|---|---|
.none |
No mode controls |
.keywordWakeup |
.disabled, .basic
|
.common |
.disabled, .basic, .advanced
|
guard let voiceAssistant = device as? OnDeviceVoiceAssistantAPI else {
print("On-device voice assistant is not supported")
return
}
print("Current mode: \(voiceAssistant.onDeviceVoiceAssistantMode)")
guard voiceAssistant.onDeviceVoiceAssistantCapability == .common else {
print("Advanced mode is not supported")
return
}
voiceAssistant.setOnDeviceVoiceAssistantMode(.advanced) { success, error in
guard success else {
print(error?.localizedDescription ?? "Unable to change mode")
return
}
print("Mode changed to advanced")
}id<AIBudsOnDeviceVoiceAssistantAPI> voiceAssistant =
(id<AIBudsOnDeviceVoiceAssistantAPI>)self.device;
if (![voiceAssistant conformsToProtocol:@protocol(AIBudsOnDeviceVoiceAssistantAPI)]) {
NSLog(@"On-device voice assistant is not supported");
return;
}
NSLog(@"Current mode: %ld", (long)voiceAssistant.onDeviceVoiceAssistantMode);
if (voiceAssistant.onDeviceVoiceAssistantCapability !=
AIBudsOnDeviceVoiceAssistantCapabilityCommon) {
NSLog(@"Advanced mode is not supported");
return;
}
[voiceAssistant
setOnDeviceVoiceAssistantMode:AIBudsOnDeviceVoiceAssistantModeAdvanced
completion:^(BOOL success, NSError *error) {
if (!success) {
NSLog(@"%@", error.localizedDescription ?: @"Unable to change mode");
return;
}
NSLog(@"Mode changed to advanced");
}];-
.unknownrepresents unavailable state and must not be sent as a target mode. - A successful callback confirms the request. Refresh UI from the device property or mode-change delegate callback.
-
.advancedincludes call-state voice control and should only be offered for.commoncapability.
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