Share via


Callback functions

Implement these functions to receive information and events from DAXKit.

DAXKitDelegate callback functions

didReceiveSupportedLanguages()

Called to inform the integration about supported languages for recording and for the AI-generated report. The values passed to this callback can be supplied to the DAX.shared.session() and DAXSession.startRecording() functions.

func didReceiveSupportedLanguages(recordingLocales: [Locale], reportLocales: [Locale])
  • recordingLocales - a list of locales supported for recording audio.
  • reportLocales - a list of locales supported for the AI-generated report.

Important

If the didReceiveSupportedLanguages() callback retrieves an empty list of recording locales, the your app shouldn't set the recording language, but should instead leave it empty and let Dragon Copilot use its own defaults. This is important in case there are per-user or per-organization language settings, where we can't pick a reasonable default.

recordingPermission()

Called when DAXKit requests permission to record and returns whether the user granted permissions. If the mobile app requested microphone permissions prior to DAXKit starting a recording, this won't be called.

func recordingPermission(granted: Bool)

RecordingDelegate callback functions

didStartRecording()

Called when DAXKit successfully starts to record. This covers the potential gap between calling session.startRecording() and the actual start of recording, which might take a few seconds depending on the state of the device.

func didStartRecording(recordingIdentifier: String, sessionIdentifier: String, audioInputDevice: AudioInputDevice)
  • recordingIdentifier - the unique identifier of the recording.

  • sessionIdentifier - the correlation identifier of the encounter.

  • audioInputDevice - the audio input device used for the recording. AudioInputDevice members:

    • type - AudioInputDeviceType enum value.

    • name - the device name as a string.

    AudioInputDeviceType values:

    • builtInMic - the mobile device's built-in microphone.

    • other - an input device recognized by the system, but not the built-in microphone.

didFailToStartRecording()

Called if there's a failure to start recording for any reason. For example, unable to activate the audio session because a phone call is in progress.

func didFailToStartRecording(sessionIdentifier: String, error: Error)
  • sessionIdentifier - the unique identifier of the encounter.
  • error - The error associated with the failure to start recording.

didStopRecording()

Called when a recording stops, with information on the length of the recording. This can be because the user explicitly stopped the recording or because there was an audio interruption.

func didStopRecording(recordingIdentifier: String, sessionIdentifier: String, recordingDuration: TimeInterval)
  • recordingIdentifier - the unique identifier of the recording.
  • sessionIdentifier - the correlation identifier of the encounter.
  • recordingDuration - the recording duration.

recordedAudio()

Fired multiple times per second while recording is active, with information on the microphone audio level. Use this callback to show the audio level to the user.

func recordedAudio(withDuration duration: TimeInterval, audioLevel level: Float)
  • duration - the amount of audio recorded so far in the current recording, in seconds.
  • audioLevel - a value between 0 and 1, representing the audio level of the current audio interval.

recordingInterrupted()

This function is called in the following scenarios:

  • When the audio is interrupted (for example, by an incoming phone call).
  • When Apple Media Services is reset (for example, when Apple's audio system encounters problems).
  • When the audio source changes (for example, when the user connects to their Bluetooth headset).
  • When the maximum duration of a session is reached while recording.
func recordingInterrupted(reason: RecordingInterruptionReason)
  • reason - the reason for the interruption. Possible values:

    audioInterruption - an audio interruption was caused by another app taking over the audio system.

    systemError - a system error caused the recording to complete prematurely.

    reachedMaxDuration - the recording has reached the maximum recording duration for a session.

    incompatibleInputDevice - the recording route has changed and iOS hasn't provided DAXKit with a new input device.

    audioRouteChanged - a microphone connects/disconnects during recording. This includes Bluetooth microphones.

reachedWarnDuration()

Called when the total recording duration for a session reaches the warning threshold.

func reachedWarnDuration(timeLeft: TimeInterval)
  • timeLeft - the amount of time left to record for the session.

digitalSilenceDetected()

Called when DAXKit detects 1/3 second of digital silence during recording (only zeros in the audio stream). DAXKit issues a notification when digital silence has been detected but continues recording; you can choose whether to stop the recording in response to the notification. We recommend interrupting the recording and displaying an alert to the user.

func digitalSilenceDetected()

uploadedRecording()

Called when a recording is successfully uploaded to the DAX server.

func uploadedRecording(recordingIdentifier: String, sessionIdentifier: String)
  • recordingIdentifier - the unique identifier of the recording.
  • sessionIdentifier - the correlation ID that was passed to DAX.shared.session().

uploadFailed()

This function is called when a recording fails to upload successfully. It can be called multiple times per recording if DAXKit tries and fails several times to upload it.

func uploadFailed(recordingIdentifier: String, sessionIdentifier: String, error: Error, willRetryUpload: Bool)
  • recordingIdentifier - the unique identifier of the recording.
  • sessionIdentifier - the correlation ID that was passed to DAX.session().
  • error - the error that caused the upload to fail.
  • willRetryUpload - True if the upload will be retried.

didStartUpload()

Called when a recording starts to upload to Dragon Copilot. This function can be called multiple times in case of incomplete upload attempts.

func didStartUpload(recordingIdentifier: String, sessionIdentifier: String)
  • recordingIdentifier - the unique identifier of the recording.
  • sessionIdentifier - the correlation ID that was passed into DAX.session(withIdentifier:).

didFinishAllUploads()

Called when no more recordings are pending upload.

func didFinishAllUploads()