メインコンテンツまでスキップ

独自 AI サービスの認証結果を通知

reportSelfAiServiceAuthResult はデバイス側フローを同期するための通知であり、認証 API ではありません。アプリが独自の AI サービスを組み込む場合は、そのサービスをアプリ側で認証してから、結果を接続中のデバイスへ通知します。

デバイスは、独自 AI サービスの認証成功が通知されるまで、対象の AI 処理を継続しません。通知しないと、ホスト側サービスの準備ができていてもデバイス側の AI 経路はブロックされたままとなり、たとえばセッションに必要な Opus 音声ストリームが開始されない場合があります。

この API が必要な場合​

ホストアプリが組み込みと認証を担当する AI サービスで、この API を使用します。ホスト側の認証処理が完了したら、次のように通知します。

  1. 独自 AI サービスが利用可能になった後にだけ true を通知します。
  2. 認証に失敗した場合やサービスを利用できない場合は false を通知します。
  3. 完了ハンドラーが成功してから、結果がデバイスへ届いたものとして扱います。

SDK が提供する AI サービスの認証には専用の導入フローがあります。この API をサービスプロバイダー認証の代わりに使用する必要はありません。

API Reference​

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

完了ハンドラーは、結果がデバイスへ通知されたかどうかを示します。AI サービスを認証するものではありません。この API が受け付けるのは真偽値の結果だけです。アクセストークンや認証情報を送信しないでください。