मुख्य कंटेंट तक स्किप करें

अपनी 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 पूरा होने के बाद:

  1. अपनी AI service उपयोग के लिए ready होने के बाद ही true report करें।
  2. Authentication fail हो या service unavailable हो तो false report करें।
  3. Result को device तक पहुँचा मानने से पहले completion handler के success की प्रतीक्षा करें।

SDK-provided AI services का authentication अपना integration flow उपयोग करता है; host app को provider authentication के बदले यह API उपयोग नहीं करनी चाहिए।

API संदर्भ

Swift
/// 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?
)

reportSelfAiServiceAuthResult देखें।

उपयोग के उदाहरण

Swift
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")
        }
    }
}

Completion handler केवल बताता है कि result डिवाइस तक पहुँचा या नहीं; यह AI service authenticate नहीं करता। इस API से access token या credentials कभी न भेजें—यह केवल Boolean result स्वीकार करता है।