-
Notifications
You must be signed in to change notification settings - Fork 0
Core Auth Notify Ai Auth Result
reportSelfAiServiceAuthResult is a device-flow synchronization signal, not an authentication API. When the app integrates its own AI service, it authenticates that service independently and then reports the result to the connected device.
The device waits for a successful self-AI authorization result before continuing eligible AI workflows. Without that report, the host service may already be ready while the device still keeps the AI path blocked—for example, it may not start the Opus voice stream required by the session.
Use this API for an AI service integrated and authenticated by the host app. After the host authentication attempt finishes:
- Report
trueonly after the self-AI service is ready for use. - Report
falsewhen authentication fails or the service is unavailable. - Wait for the completion handler to succeed before treating the result as delivered to the device.
SDK-provided AI service authentication follows its own integration flow and does not require the host app to use this API as a substitute for provider authentication.
/// Reports the authentication result for the self-AI service.
/// - Parameters:
/// - isAuthenticated: Whether the self-AI service is authenticated.
/// - completion: A closure that is called when the operation completes.
/// - success: `true` if the operation was successful; otherwise `false`.
/// - error: An `NSError` object that describes the error that occurred, or `nil` if the operation was successful.
func reportSelfAiServiceAuthResult(
_ isAuthenticated: Bool,
completion: AIBudsCompletionHandler?
)/// Reports the authentication result for the self-AI service.
- (void)reportSelfAiServiceAuthResult:(BOOL)isAuthenticated
completion:(AIBudsCompletionHandler _Nullable)completion;See reportSelfAiServiceAuthResult.
func selfAIAuthenticationDidFinish(isAuthenticated: Bool) {
guard let device = device as? DeviceServiceAuthAPI else { return }
// Report the result only after the host app's own AI authorization finishes.
device.reportSelfAiServiceAuthResult(isAuthenticated) { reportSucceeded, error in
guard reportSucceeded else {
print(error?.localizedDescription ?? "Failed to report authorization")
return
}
if isAuthenticated {
// The device can now continue eligible AI flows, including an Opus input stream.
print("Self-AI authorization delivered to the device")
}
}
}- (void)selfAIAuthenticationDidFinish:(BOOL)isAuthenticated {
id<AIBudsDeviceServiceAuthAPI> device = (id<AIBudsDeviceServiceAuthAPI>)self.device;
if (![device conformsToProtocol:@protocol(AIBudsDeviceServiceAuthAPI)])
return;
// Report the result only after the host app's own AI authorization finishes.
[device reportSelfAiServiceAuthResult:isAuthenticated
completion:^(BOOL reportSucceeded, NSError *error) {
if (!reportSucceeded) {
NSLog(@"%@", error.localizedDescription);
return;
}
if (isAuthenticated) {
// The device can now continue eligible AI flows, including
// an Opus input stream.
NSLog(@"Self-AI authorization delivered to the device");
}
}];
}The completion handler reports whether the result was delivered to the device; it does not authenticate the AI service. Never send access tokens or credentials through this API—it accepts only the Boolean result.
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