Logo
Search
API Docs

iOS SDK Integration

Chat Agents

iOS SDK Integration & the Client/Delegate Pattern

Overview

The iOS SDK lets you add voice-assistant calling to a native Swift app using a client-and-delegate pattern: you instantiate a client with your public API key, then implement a delegate protocol to receive call lifecycle events. This follows the same integration model as the Web SDK Integration and React Native SDK Integration guides — a client you start/stop, paired with an event mechanism for reacting to what happens during the call.


Installation

Add the iOS SDK to your Swift project through your usual dependency manager, then import it:

import SulusVoiceSDK

Client & Delegate Pattern

Initialize SulusVoiceClient with your public API key, then assign a delegate to receive call lifecycle events:

class VoiceViewController: UIViewController {
    private let sulusVoice = SulusVoiceClient(apiKey: "YOUR_PUBLIC_API_KEY")

    override func viewDidLoad() {
        super.viewDidLoad()
        sulusVoice.delegate = self
    }
}

Conform to SulusVoiceClientDelegate to handle events such as call-started and call-ended:

extension VoiceViewController: SulusVoiceClientDelegate {
    func sulusVoiceCallDidStart() {
        print("Call started")
    }

    func sulusVoiceCallDidEnd() {
        print("Call ended")
    }
}
  • SulusVoiceClient(apiKey:) — initializes the client with your public API key
  • sulusVoice.delegate — assign a conforming object to receive call events
  • sulusVoiceCallDidStart() / sulusVoiceCallDidEnd() — delegate methods fired at the start and end of a call

Basic Swift Example

A view controller with a start-call button action, wired to the delegate methods above:

class VoiceViewController: UIViewController {
    private let sulusVoice = SulusVoiceClient(apiKey: "YOUR_PUBLIC_API_KEY")

    override func viewDidLoad() {
        super.viewDidLoad()
        sulusVoice.delegate = self
    }

    @IBAction func startCallTapped(_ sender: UIButton) {
        sulusVoice.start(assistantId: "YOUR_ASSISTANT_ID")
    }

    @IBAction func endCallTapped(_ sender: UIButton) {
        sulusVoice.stop()
    }
}

extension VoiceViewController: SulusVoiceClientDelegate {
    func sulusVoiceCallDidStart() {
        print("Call started")
    }

    func sulusVoiceCallDidEnd() {
        print("Call ended")
    }
}

Starting & Stopping Calls

  • Start a call with sulusVoice.start(assistantId: "YOUR_ASSISTANT_ID")
  • End a call with sulusVoice.stop()

The delegate pattern lets your view controller respond to call lifecycle events without tightly coupling UI logic to the SDK internals.


Next Steps

  • A Sulus account with your public API key, and an existing assistant ID, are required before you start
  • Create an assistant from the dashboard, or programmatically via a server-side SDK, if you don't have an assistant ID yet
  • Extend the delegate to handle additional lifecycle events and drive richer UI states (connecting, speaking, error)
  • Display a live transcript by handling message-type events on the delegate

This SDK follows the same integration model as the Web SDK Integration and React Native SDK Integration guides.