अपनी AI सेवा का प्रमाणीकरण परिणाम बताएँ
reportSelfAiServiceAuthResult device workflow को sync करने वाला signal है, authentication API नहीं। App अपनी AI service जोड़ने पर उसे स्वतंत्र रूप से authenticate करता है और फिर परिणाम connected device को बताता है।
डिवाइस योग्य AI workflows जारी रखने से पहले अपनी AI service के सफल authorization result की प्रतीक्षा करता है। Result report न होने पर host service तैयार हो सकती है, लेकिन device AI path blocked रखेगा—उदाहरण के लिए session के लिए आवश्यक Opus voice stream शुरू नहीं होगा।
यह API कब आवश्यक है
Host app द्वारा integrated और authenticated AI service के लिए यह API उपयोग करें। Host authentication पूरा होने के बाद:
- अपनी AI service उपयोग के लिए ready होने के बाद ही
truereport करें। - Authentication fail हो या service unavailable हो तो
falsereport करें। - Result को device तक पहुँचा मानने से पहले completion handler के success की प्रतीक्षा करें।
SDK-provided AI services का authentication अपना integration flow उपयोग करता है; host app को provider authentication के बदले यह API उपयोग नहीं करनी चाहिए।
API संदर्भ
- Swift
- Objective-C
/// 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;reportSelfAiServiceAuthResult देखें।
उपयोग के उदाहरण
- Swift
- Objective-C
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");
}
}];
}Completion handler केवल बताता है कि result डिवाइस तक पहुँचा या नहीं; यह AI service authenticate नहीं करता। इस API से access token या credentials कभी न भेजें—यह केवल Boolean result स्वीकार करता है।