--- title: NowVoiceCallbacks structure - iOS description: Specifies callbacks for voice session lifecycle and content events.Creates a NowVoiceCallbacks instance with the specified voice session event handlers. locale: en-US canonical_url: https://www.servicenow.com/docs/r/australia/api-reference/cllent-mobile-api-reference/NowVoiceCallbacksiOSStruct.html release: australia product: Cllent Mobile API Reference classification: cllent-mobile-api-reference topic_type: concept last_updated: "2026-07-14" reading_time_minutes: 1 breadcrumb: [Mobile SDK - iOS, Mobile SDK API reference, API reference, API implementation and reference] --- # NowVoiceCallbacks structure- iOS Specifies callbacks for voice session lifecycle and content events. **Parent Topic:**[Mobile SDK - iOS](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/cllent-mobile-api-reference/MobileSDKiOSAPI.md) ## 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](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/cllent-mobile-api-reference/NVoiceTrnstMsgiOSta.md)\) -> 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 ``` - **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.
onCallMinimized \(\(\) -> Void\)? 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.
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") } ) ```