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

設定

各機能を使用する前に、ログ、Bluetooth 検索、デバイス接続、AI サービスを設定します。

基本設定

ログレベル

SDK の初期化時に渡す設定でログレベルを指定します。

Swift
let sdkConfiguration = SDKConfiguration.default()

// Default: .info
// All-in-One uses .verbose only when it creates this configuration for you.
sdkConfiguration.logLevel = .info

let initialized = AIBudsAllInOneSDK.initialize(
    configuration: sdkConfiguration,
    delegate: self
)

guard initialized else {
    print("AIBuds SDK initialization failed.")
    return
}

// Log levels, from most to least verbose:
// .verbose, .debug, .info, .warn, .error, .fatal, .mute

// Modular installation:
// AIBudsSDK.initialize(appDelegate, configuration: sdkConfiguration, delegate: self)

モジュール単位の初期化手順は、クイックスタートを参照してください。

ログの出力先

共有の LogConfiguration でログの出力先を選択します。

Swift
let logConfig = LogConfiguration.shared

// Default: .xlfacility
logConfig.destination = .console

// Available destinations:
// .console    — Xcode debugger console
// .oslogger   — Unified logging through os_log
// .file       — SDK-managed files on disk
// .xlfacility — XLFacility plugin

// All-in-One installs the XLFacility plugin automatically.
// Modular integrations must install AIBudsSDK/Log/XLFacility explicitly.

ログの保存、エクスポート、削除については、ログの概要を参照してください。

詳細設定

Bluetooth 設定

検索タイムアウト

初期化前に既定のタイムアウトを設定するか、個別の検索時に値を上書きします。

Swift
// Defaults:
// scanTimeoutInSeconds = 10; use 0 for no automatic timeout.
// shouldAutoReconnectWhenAppLaunch = false
// onlyDiscoverKnownDevices = true
let sdkConfiguration = SDKConfiguration.default()
sdkConfiguration.scanTimeoutInSeconds = 15

// 15 overrides the initialized configuration for this scan only.
AIBudsSDK.startScanning(
    NSNumber(value: 15),
    deviceFoundHandler: { device, isExistingDevice in
        // isExistingDevice is true when an existing result was updated.
    },
    completion: {
        // Called when scanning stops.
    }
)

// Use the timeout supplied during SDK initialization.
AIBudsSDK.startScanning(nil)

接続パラメータ

接続ごとの値は ConnectParams で渡します。

Swift
let params = ConnectParams()
params.userId = currentUserId  // Only when required by the integration.
params.randomCode = devicePairingCode  // Only when required by the device.
params.enableClassicBT = true  // Default: true; false enables BLE-only use.
params.aiAuthParams = aiAuthParams  // Only when required by the AI provider.

device.connect(params)

AI 設定

AI サービスをインストール、登録、初期化した後に、使用するサービスを選択します。

Swift
// 1. Install the provider module.
// 2. Register and initialize the provider with AIBudsAISDK.
// 3. Select the registered provider.
AIBudsAISDK.setAIServiceVendor(.starBurst)

// Other public values:
// .mltcloud
// .none       // No provider is selected.

設定手順の全体は、AI サービスを選択を参照してください。

次のステップ

設定が完了したら、主要概念に進んでください。用語は SDK 用語集、各機能はコア機能、初期化・検索・接続・AI サービス選択の問題はよくある問題で確認できます。