Kendi AI Hizmetinizin Yetkilendirme Sonucunu Bildirme
reportSelfAiServiceAuthResult bir kimlik doğrulama API'si değil, cihaz akışını eşitleyen bir sinyaldir. Uygulama kendi AI hizmetini entegre ettiğinde bu hizmetin kimlik doğrulamasını bağımsız olarak yapar ve sonucu bağlı cihaza bildirir.
Cihaz, ilgili AI akışlarına devam etmeden önce kendi AI hizmetiniz için başarılı bir yetkilendirme sonucu bekler. Sonuç bildirilmezse ana uygulamadaki hizmet hazır olsa bile cihaz AI yolunu kapalı tutar; örneğin oturumun gerektirdiği Opus ses akışını başlatmayabilir.
Bu API Ne Zaman Gereklidir?
Ana uygulamanın entegre edip kimliğini doğruladığı bir AI hizmeti için bu API'yi kullanın. Ana uygulamadaki kimlik doğrulama denemesi tamamlandıktan sonra:
- Yalnızca kendi AI hizmetiniz kullanıma hazır olduğunda
truebildirin. - Kimlik doğrulama başarısız olduğunda veya hizmet kullanılamadığında
falsebildirin. - Sonucun cihaza ulaştığını kabul etmeden önce completion handler'ın başarılı olmasını bekleyin.
SDK tarafından sağlanan AI hizmetlerinin kimlik doğrulaması kendi entegrasyon akışını izler. Ana uygulama bu API'yi hizmet sağlayıcı kimlik doğrulamasının yerine kullanmamalıdır.
API Referansı
- 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;Bkz. reportSelfAiServiceAuthResult.
Kullanım Örnekleri
- 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 yalnızca sonucun cihaza iletilip iletilmediğini bildirir; AI hizmetinin kimliğini doğrulamaz. Bu API üzerinden erişim belirteci veya kimlik bilgisi göndermeyin; API yalnızca Boolean sonucu kabul eder.