Skip to main content

Overview

The SDK uses a delegate pattern to broadcast important events that occur during a session’s lifecycle. By conforming to the SukiAmbientSessionDelegate protocol, you can receive real-time updates and respond to state changes in your application, such as updating your UI or handling errors.

How To Implement The Session Delegate

1. Conform To The Protocol

First, declare that your class conforms to the SukiAmbientSessionDelegate protocol. You must also pass an instance of this delegate class when you initialize the SDK.

2. Implement The Delegate Method

Next, implement the sukiAmbient(sessionEvent:for:) method. The SDK calls this method every time a new session event occurs, providing the event type and the associated recordingId. You can use a switch statement within this method to handle the events that are relevant to your application.
extension YourViewController: SukiAmbientSessionDelegate {
    func sukiAmbient(sessionEvent event: SukiAmbientCore.SessionEvent, for recordingId: SukiAmbientCore.RecordingId) {
        // This method receives all session events for a given recording ID.
        print("Received event: \(event) for recording ID: \(recordingId)")

        // Use a switch statement to handle specific events.
        switch event {
        case .started:
            // Update your UI to show that recording has started.
            break
        case .suggestionsGenerated:
            // Notify the user that their note is ready.
            break
        case .convertedToOfflineSession:
            // Inform the user about the network issue.
            break
        // Handle other cases as needed for your app's logic.
        default:
            break
        }
    }
}

Available Session Events

The SessionEvent enum provides the following cases, which are grouped by category for clarity.

Recording Lifecycle

SessionEvent
enum
Recording lifecycle events for ambient sessions.

Content Generation

SessionEvent
enum
Content generation events for note suggestions.

Offline Mode & Uploading

SessionEvent
enum
Offline mode and audio upload events.

Audio Interruptions

SessionEvent
enum
Audio interruption events during recording.
public enum SessionEvent {
    case started
    case resumed
    case paused
    case ended
    case cancelled
    case suggestionGenerationInProgress
    case suggestionsGenerated
    case suggestionsGenerationFailed
    case audioInterruptionStarted
    case audioInterruptionEnded
    case convertedToOfflineSession
    case pendingOfflineUpload
    case preparingOfflineUpload
    case uploadingAudio
    case audioUploadFailed
    case audioUploadAllRetryFailed
    case audioUploaded
    case processingUpload
    case processingUploadFailed
}

FAQs

Yes, you can listen to the following events:
  • sessionEvent
  • recordingId
No, you cannot create a new case inside the SessionEvent enum. You must use the existing cases.
We have so many cases because we want to be able to handle all the possible events that can occur during a session.
I