NowVoiceCallbacks structure - iOS

concept brazil Updated Sep 10, 2026 1 min read NowVoiceCallbacksiOSStruct.md
Raw file servicenow.com

Specifies callbacks for voice session lifecycle and content events.

Parent Topic:Mobile SDK - iOS

NowVoiceCallbacks - init(onMuteStateChanged: ((Bool) -> Void)?, onMessageReceived: ((NowVoiceTranscriptMessage) -> Void)?, onCallEnded: NowVoiceDismissHandler?, onCallMinimized: (() -> Void)?)

Creates a NowVoiceCallbacks instance with the specified voice session event handlers.

A VoiceAgentError is delivered as the second parameter of the onCallEnded callback.

Case Description
.connectionTimeout The connection to the voice agent timed out.
.connectionFailed A connection to the voice agent could not be established.
.disconnectedUnexpectedly The connection dropped during an active session.
.serverEnded The server terminated the session.

Name

Type

Description

onMuteStateChanged

((Bool) -> Void)?

Called each time the user mutes or unmutes the microphone. The Bool parameter is true when the microphone is muted.

onMessageReceived

((NowVoiceTranscriptMessage) -> Void)?

Called each time a new transcript message arrives during the session.

onCallEnded

NowVoiceDismissHandler?

Called when the voice UI is dismissed.``` public typealias NowVoiceDismissHandler = ( _ conversationId: String?, _ error: VoiceAgentError?, _ endedFromCallKitUI: Bool ) -> Void

Text
-   **conversationId**: Conversation ID.-   **error**: Optional error containing the reason the call ended.-   **endedFromCallKitUI**: `true` when the call was ended by the user from the iOS CallKit UI \(lock screen or Dynamic Island\). `false` for all in-app dismissals.
</td></tr><tr><td>
onCallMinimized
</td><td>
\(\(\) -&gt; Void\)?
</td><td>
Called when the voice session UI is minimized by the user \(the call remains active in the background\). Providing this callback is what surfaces the minimize button in the voice UI.
</td></tr></tbody></table>The following code example shows how to initialize a NowVoiceCallbacks. In each callback function, implement the desired functionality for handling the event.

let callbacks = NowVoiceCallbacks( onMuteStateChanged: { isMuted in // Update your UI to reflect the current mute state. print("Microphone muted: (isMuted)") }, onMessageReceived: { message in // Receive real-time transcript messages during the session. print("[(message.role)]: (message.content)") }, onCallEnded: { conversationId, error, endedFromCallKitUI in // Called when the voice session ends. if let error { print("Session ended with error: (error)") } else { print("Session complete. Conversation ID: (conversationId ?? "unknown")") } }, onCallMinimized: { // Called when the voice UI is minimized. print("Voice chat is minimized") } )

Text

Search documentation
Search document titles and file paths on the brazil branch