Zum Inhalt springen
Busymate AI

Dieser Leitfaden ist derzeit nur auf Englisch verfügbar.

Leitfäden

iOS-SDK installieren und konfigurieren

Installiere das versionierte iOS-SDK, konfiguriere Identität und Mikrofonberechtigung und kompiliere die Beispiel-App.

Auf dieser Seite

Install the official iOS SDK distribution 1.0.5 (microphone adapter 1.0.1) in a UIKit or SwiftUI app. Channel, identity, microphone protocol and release rules are shared by every platform on Native SDKs; this page covers only what differs on iOS. Source and the configuration reference live in the public repository, and the release is 1.0.5.

1. Install the pinned version

  1. In Xcode Package Dependencies, add https://github.com/serebano/busymate-ai-sdk-ios.git, select exact version 1.0.5 and link the BusymateAI product. Import BusymateAI and WebKit.
  2. SDK distribution 1.0.5 requires iOS 15 or later.
  3. Set channel=ios on the chat URL.

The versioned README lists every step.

2. Install the bridge before loading chat

Configure your account and backend callbacks, then install BusymateBridge before the first navigation.

swift
// Swift Package: https://github.com/serebano/busymate-ai-sdk-ios.git (exact 1.0.5)
// Full lifecycle + demo: https://busymate.ai/docs/guides/ios-sdk
import WebKit
import BusymateAI

@MainActor
func installAssistant(
  on webView: WKWebView,
  account: @escaping () -> String?,
  mint: @escaping @MainActor (BusymateBridge.MintRequest) async throws -> BusymateBridge.MintToken?
) {
  BusymateBridge.install(on: webView, config: .init(
    assistant: "your-assistant",
    origins: ["https://your-assistant.busymate.ai"],
    account: account,
    mint: mint
  ))
  // mint calls YOUR authenticated backend with request.nonce; never cache tokens.
  // Backend endpoint: https://YOUR-PRODUCT-DOMAIN/api/bmai/identity
  webView.load(URLRequest(url: URL(string: "https://your-assistant.busymate.ai/?channel=ios")!))
}
// Declare NSMicrophoneUsageDescription + NSCameraUsageDescription (Take Photo in
// the + menu); retain BusymateMicrophone, forward WKUIDelegate media permission.
// Call BusymateBridge.accountChanged() on login/logout/account changes.

The options are assistant, origins, account, mint, onAction, onClose and, for sign-in through ASWebAuthenticationSession, an optional authCallbackScheme that you also register in your app URL types. See the configuration reference.

Forward webViewWebContentProcessDidTerminate to BusymateBridge.contentProcessDidTerminate. In SwiftUI, install in makeUIView, retain through the Coordinator, never install again in updateUIView, and remove the microphone handler in dismantleUIView. The frozen identity bridge has no public uninstall API.

3. Wire the microphone

Add NSMicrophoneUsageDescription to your Info.plist. Retain BusymateMicrophone and forward WKUIDelegate.requestMediaCapturePermissionFor to allowMedia(origin:type:). See microphone lifecycle and troubleshooting.

The adapter source, BusymateMicrophone.swift, is attached to the release with SHA256SUMS. The latest release carries the current file.

4. Let visitors attach files

The chat's attach (+) button works in WKWebView with no delegate code: WebKit shows Photo Library, Take Photo and Choose Files. Add NSCameraUsageDescription to your Info.plist: without it iOS closes the app when the user picks Take Photo, and WebKit cannot hide that item. BusymateMicrophone logs a fault at install when the key is missing (BusymateFiles.checkHost()). Photo Library and Choose Files need no key (the system pickers run outside your app); the example app also declares NSPhotoLibraryUsageDescription so the wording is ready if you add your own photo access. See attachments.

5. Run the demo

Follow the example-app instructions. Test the first microphone grant, a denial and a cancellation on a physical device.