NowVoiceService class - iOS

concept australia Updated Sep 10, 2026 5 min read NowVoiceServiceiOSAPI.md
Raw file servicenow.com

The NowVoiceService class manages voice agent sessions for a single ServiceNow instance.

Note: Initialize a NowVoiceService by calling NowVoice - makeVoiceService(instanceUrl: URL) async throws.

Name

Type

Description

configuration

NowServiceConfiguration

The service configuration for the ServiceNow instance.

configurations

Array of NowVoiceEndpoints

List of available voice endpoint configurations retrieved from the instance.

isMuted

Bool

Flag that indicates the microphone mute state for the current call. Setting this property has no effect if no call is currently active.Valid values:

  • true: The microphone is muted.
  • false: The microphone is unmuted or no call is active.

voiceEnabled

Bool

Flag that indicates whether voice is enabled on the instance. Valid values:

  • true: Voice is enabled.
  • false: Voice is turned off.

Always true after a NowVoiceService is successfully initialized with makeVoiceService(instanceUrl:).

**Parent Topic:**[Mobile SDK - iOS](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/cllent-mobile-api-reference/MobileSDKiOSAPI.md)

NowVoiceService - endCall()

Ends the current voice call.

Has no effect if no call is active.

Name Type Description
None
Type Description
None

The following code example shows how to call this function.

JavaScript
let voiceService = try? await NowVoice.makeVoiceService(instanceUrl: instanceUrl)let endpoint = voiceService?.configurations.first
if let voiceService, let endpoint {    if let vc = try? await voiceService.startVoice(endpoint: endpoint, theme: theme) {        vc.modalPresentationStyle = .fullScreen        present(vc, animated: true)    }}
// End a call on timeout, navigation, or from a custom hang-up buttonvoiceService?.endCall()

NowVoiceService - hasActiveCall()

Checks whether there is a currently active voice call.

Name Type Description
None

Type

Description

Boolean

Flag that indicates whether there is an active voice call.Valid values:

  • true: There is an active voice call.
  • false: There isn't an active voice call.
The following code example shows how to call this function.
JavaScript
let voiceService = try? await NowVoice.makeVoiceService(instanceUrl: instanceUrl)let endpoint = voiceService?.configurations.first
if let voiceService, let endpoint {    if let vc = try? await voiceService.startVoice(endpoint: endpoint, theme: theme) {        vc.modalPresentationStyle = .fullScreen        present(vc, animated: true)    }}
// Guard UI state or prevent starting a second callif voiceService?.hasActiveCall() == true {    // A voice call is currently in progress}

NowVoiceService - startVoice(endpoint: NowVoiceEndpoint, uiConfiguration: NowVoiceUIConfiguration, callbacks: NowVoiceCallbacks, theme: NowVoiceThemeable) async throws

Creates a UIViewController containing the voice agent UI, ready to be presented in a modal.

The UIViewController manages the full voice session lifecycle, including teardown on dismissal.

This function fetches an OAuth access token automatically before launching the voice UI.

Name

Type

Description

endpoint

NowVoiceEndpoint

The voice agent channel to connect to. Obtain from NowVoiceService.configurations. Endpoints are retrieved from your ServiceNow instance's Mobile SDK settings.

uiConfiguration

NowVoiceUIConfiguration

Optional. Presentation options for the voice agent UI. If omitted, uses the default values for NowVoiceUIConfiguration.

callbacks

NowVoiceCallbacks

Optional. Callbacks for voice session events. If omitted, events are silently ignored.

theme

NowVoiceThemeable

Optional. The visual theme applied to the voice UI.Default: NowVoiceDefaultTheme

|Type|Description| |----|-----------| |UIViewController|A UIViewController containing the full-screen voice agent interface. Present it in a modal. Set `modalPresentationStyle = .fullScreen` for the intended experience.|

The following code example shows how to call this function.

JavaScript
import NowVoice
let instanceUrl = URL(string: "https://your-instance.service-now.com")!
let voiceService = try? await NowVoice.makeVoiceService(instanceUrl: instanceUrl)
guard let voiceService, let endpoint = voiceService.configurations.first else {    // Either the service failed to initialize, or no voice endpoints are configured.    return}
// Launch the voice agent UIlet vc = try await voiceService.startVoice(    endpoint: endpoint,    uiConfiguration: NowVoiceUIConfiguration(        hidesPostCallTranscript: false,        shouldBlockTranscriptSharing: false    ),    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")        }    ),    theme: NowVoiceDefaultTheme())
//Present the voice agent UI in a full-screen modalvc.modalPresentationStyle = .fullScreenpresent(vc, animated: true)

NowVoiceService - toggleMute()

Toggles the microphone mute state of the current call.

Name Type Description
None

Type

Description

Bool

Flag that indicates the new microphone mute state for the current call.Valid values:

  • true: The microphone is now muted.
  • false: The microphone is now unmuted or no call is active.
The following code example shows how to call this function.
JavaScript
let voiceService = try? await NowVoice.makeVoiceService(instanceUrl: instanceUrl)
let endpoint = voiceService?.configurations.first
if let voiceService, let endpoint {    if let vc = try? await voiceService.startVoice(endpoint: endpoint, theme: theme) {        vc.modalPresentationStyle = .fullScreen        present(vc, animated: true)    }}
// Wire to a custom mute button or auto-mute on backgroundingvoiceService?.toggleMute()
// Check mute state to update a custom mute button iconlet muted = voiceService?.isMuted ?? false

NowVoiceService - updateTheme(theme: NowVoiceThemeable)

Updates the visual theme of the currently active voice UI.

This function has no effect if no voice session is currently active. To apply a visual theme at voice session launch, provide a theme when calling startVoice(endpoint:uiConfiguration:callbacks:theme:).

Name Type Description
theme NowVoiceThemeable The theme to apply to the active voice UI.
Type Description
None

The following code example updates the visual theme of the currently active voice UI.

JavaScript
import NowVoice
let instanceUrl = URL(string: "https://your-instance.service-now.com")!let voiceService = try? await NowVoice.makeVoiceService(instanceUrl: instanceUrl)
struct MyVoiceTheme: NowVoiceThemeable { var color: NowUIColoring = MyAppColors()}
// Update the theme while a voice session is activevoiceService?.updateTheme(theme: MyVoiceTheme())
Search documentation
Search document titles and file paths on the australia branch