NowChatConfiguration class - iOS

concept australia Updated Sep 10, 2026 9 min read NowChatOptionsiOS.md
Raw file servicenow.com

Configures options on a chat session.

Use cases:

  • Showing a prompt before closing a chat window.
  • Turning off features while using chat.
  • Applying conversation options when using chat.
  • Configuring UI components in NowChat.

Use NowChatConfiguration properties to integrate NowVoice with NowChat.

Name Type Description
voiceConfiguration NowVoiceEndpoint? The voice endpoint for the in-chat voice button. When nil, uses the first endpoint in your ServiceNow instance's Mobile SDK settings.
voiceUIConfiguration NowVoiceUIConfiguration? Presentation options to apply to the voice UI launched from within chat.
voiceCallbacks NowVoiceCallbacks? Callbacks for voice sessions launched from within chat.

When these properties are set, a voice button appears in the NowChat UI. Tapping it launches the voice agent UI as a full-screen overlay within the chat flow. The onCallEnded callback is invoked when the voice session ends, returning the user to the chat.

Parent Topic:Mobile SDK - iOS

NowChatConfiguration - NowChatConfiguration(closePrompt: ClosePrompt?, disabledFeatures: [Feature]? = nil, conversationOptions: [ConversationOption]? = nil, uiConfiguration: UIConfiguration? = nil)

Configures options for the current chat session. This method enables you to show a prompt before closing a chat window, disable features while using chat, apply different conversation options when using chat, and configure UI components in NowChat.

Name

Type

Description

closePrompt

ClosePrompt?

Prompt to display before closing the associated chat window.Call the NowChatConfiguration.ClosePrompt() struct to define the value of this parameter.

For example:

Text
closePrompt = NowChatConfiguration.ClosePrompt(  header = nil,  message = "Are you sure you want to leave?",  acceptButtonTitle = "Yes",  declineButtonTitle = "No")

If you don't want to display a close prompt, omit the closePromptargument in the NowChatConfiguration() call.

disabledFeatures

[NowChatConfiguration.​Feature]?

List of chat features to disable within the current chat session.Valid value: startNewConversation - Hide/disable the StartNew Conversation button that appears in a chat window.

The available chat features are defined in the NowChatOptions.Feature enum class.

For example:

JavaScript
let disabledFeatures: [NowChatConfiguration.Feature]? = [.startNewConversation]

If you don't want to disable any features, omit the disabledFeatures argument in the NowChatConfiguration() call.

conversationOptions

[NowChatConfiguration.​ConversationOption]?

List of conversation options to apply to NowChat. Valid values:

  • endConversationOnExit: Ongoing conversation is terminated when exiting the NowChat window.
  • forceNewConversation: Forces a new chat conversation when NowChat starts.

The available conversation options are defined in the NowChatConfiguration.ConversationOption enum class.

For example:

JavaScript
let conversationOptions: [NowChatConfiguration.ConversationOption]? = [.endConversationOnExit, .forceNewConversation]

If you don't want to disable any features, omit the conversationOptions argument in the NowChatConfiguration() call.

uiConfiguration

UIConfiguration?

UIConfiguration values to use to configure UI components in NowChat. Valid values:

  • attachmentUploadButton: Configuration for the AttachmentUploadButton that is shown next to the text input while talking with a live agent.
  • closeButton: Configuration for the CloseButton used for back navigation on the NowChat toolbar.

For example:

JavaScript
let attachmentUploadButton = NowChatConfiguration.AttachmentUploadButton(isVisible: false) // Default isVisible = true
// Configure close button as Textlet closeButtonText: NowChatConfiguration.CloseButtonType = .text("Exit")let uiConfigurationWithText = NowChatConfiguration.UIConfiguration(closeButton: closeButtonText)
// Configure close button as image   let buttonImage = UIImage(systemName: "arrow.left.circle") ?? nil var closeButtonImage: NowChatConfiguration.CloseButtonType?   if let buttonImage { closeButtonImage = .image(buttonImage) }     let uiConfigurationWithImage = NowChatConfiguration.UIConfiguration(closeButton: closeButtonImage)

If you want to use custom images instead of the provided system images, the images should be between 22 to 44 pixels in width and 30 pixels in height, for optimal resolution.

To use the default for either AttachmentUploadButton or CloseButtonType, omit the associated button from the UIConfiguration argument.

To use the default for both buttons, omit the UIConfiguration parameter in the NowChatConfiguration() call.

|Type|Description| |----|-----------| |NowChatConfiguration|Returns a NowChatConfiguration object that you can pass when calling the [NowChatConfiguration\(\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/cllent-mobile-api-reference/NowChatOptionsiOS.md) method.|

The following code example shows how to call this method to configure the chat UI.

JavaScript
func makeChatScreen() -> UIViewController? {  let closePrompt = NowChatConfiguration.ClosePrompt(    header: nil,    message: "Are you sure you want to leave?",    acceptButtonTitle: "Yes",    declineButtonTitle: "No"  )
  let disabledFeatures: [NowChatConfiguration.Feature]? = [.startNewConversation]
  let conversationOptions: [NowChatConfiguration.ConversationOption]? = [.endConversationOnExit, .forceNewConversation] 
  let attachmentUploadButton = NowChatConfiguration.AttachmentUploadButton(isVisible: false) 
  // Configure close button as Text  let closeButtonText: NowChatConfiguration.CloseButtonType = .text("Exit")  let uiConfigurationWithText = NowChatConfiguration.UIConfiguration(closeButton: closeButtonText, attachmentUploadButton: attachmentUploadButton)    // Configure close button as image   let buttonImage = UIImage(systemName: "arrow.left.circle") ?? nil 
  var closeButtonImage: NowChatConfiguration.CloseButtonType?  if let buttonImage {    closeButtonImage = .image(buttonImage)  }  let uiConfigurationWithImage = NowChatConfiguration.UIConfiguration(closeButton: closeButtonImage, attachmentUploadButton: attachmentUploadButton)    
  let chatConfiguration = NowChatConfiguration(closePrompt: closePrompt,     disabledFeatures: disabledFeatures,    conversationOptions: conversationOptions,    uiConfiguration: uiConfigurationWithImage)
  let result = chatService.makeChatUI(theme: CarrascoChatTheme(chatColors: ChatColors()), chatConfiguration: chatConfiguration)  
  switch result {     case .success(let chatViewController):      return chatViewController    case .failure(let error):      debugPrint("Chat screen creation failed with error: \(error)")      return nil  }}

NowChatConfiguration - AttachmentUploadButton(isVisible: Boolean = true)

Defines the UI configurations to apply to the upload attachment button that appears next to the text input while talking with a live agent.

AttachmentUploadButton is a struct of the NowChatConfiguration class.

Name

Type

Description

isVisible

Boolean

Flag that indicates the visibility of the upload attachment button.Valid values:

  • true: Upload attachment button is visible.
  • false: Upload attachment button is hidden.

Default: true

|Type|Description| |----|-----------| |None| |

The following code example shows how to hide the AttachmentUploadButton.

JavaScript
func makeChatScreen() -> UIViewController? {  let attachmentUploadButton = NowChatConfiguration.AttachmentUploadButton(isVisible: false)  let uiConfigurationWithAttachmentButton = NowChatConfiguration.UIConfiguration(attachmentUploadButton: attachmentUploadButton)         
  let chatConfiguration = NowChatConfiguration(uiConfiguration: uiConfigurationWithAttachmentButton) 
  let result = chatService.makeChatUI(theme: CarrascoChatTheme(chatColors: ChatColors()), chatConfiguration: chatConfiguration) 
  switch result {    case .success(let chatViewController):      return chatViewController    case .failure(let error):      debugPrint("Chat screen creation failed with error: \(error)")      return nil  }}

NowChatConfiguration - ClosePrompt(header: String?, message: String, acceptButtonTitle: String, declineButtonTitle: String)

Creates and returns a ClosePrompt object based on the passed parameters. You then pass this object into the NowChatConfiguration() constructor to configure the close prompt options within a chat session.

Name

Type

Description

header

String

Text to display on the prompt's header.If you don't want to display a prompt header, pass "nil".

message

String

Text to display as the prompt's main text.

acceptButtonTitle

String

Text to display on the prompt's primary button for closing the chat window.

declineButtonTitle

String

Text to display on the prompt's secondary button that dismisses the prompt.

The following code example shows how to call this function.
JavaScript
func makeChatScreen() -> UIViewController? {  guard let chatService = chatService else { return nil }  let closePrompt = NowChatOptions.ClosePrompt(    header: "Close Window",    message: "Are you sure you want to close the chat window?",    acceptButtonTitle: "Yes",    declineButtonTitle: "No")
  let disabledFeatures = [.startNewConversation]      let chatOptions = NowChatOptions(closePrompt: closePrompt,    disabledFeatures: disabledFeatures,    forceNewConversation: true)      let result = chatService.makeChatUI(theme: CarrascoChatTheme(chatColors: ChatColors()), chatOptions: chatOptions)      switch result {  case .success(let chatViewController):    return chatViewController  case .failure(let error):    return nil  }}

NowChatConfiguration - UIConfiguration(closeButton: CloseButtonType? = nil, attachmentUploadButton: AttachmentUploadButton? = nil, voiceInputButton: VoiceInputButton? = nil, hideBranding: Bool = false)

Creates and returns a UIConfiguration object based on the passed parameters. You then pass this object into the NowChatConfiguration() constructor to configure UI components in NowChat.

UIConfiguration() is a struct of the NowChatConfiguration class.

Name

Type

Description

closeButton

CloseButtonType?

UI configuration for the CloseButtonType that appears on the NowChat toolbar and is used for back navigation.Valid values:

  • image (UIImage): Create a close button with an image.
  • text (String): Create a close button as text. Use this to pass a custom name for the back button.

The available CloseButtonType options are defined in the NowChatConfiguration.CloseButtonType enum class.

For example:

JavaScript
func makeChatScreen() -> UIViewController? {  // Configure close button as Text  let closeButtonText: NowChatConfiguration.CloseButtonType = .text("Exit")  let uiConfigurationWithText = NowChatConfiguration.UIConfiguration(closeButton: closeButtonText)
  // Configure close button as image  let buttonImage = UIImage(systemName: "arrow.left.circle") ?? nil
  var closeButtonImage: NowChatConfiguration.CloseButtonType?  if let buttonImage {    closeButtonImage = .image(buttonImage)  }  let uiConfigurationWithImage = NowChatConfiguration.UIConfiguration(closeButton: closeButtonImage)
  let chatConfiguration = NowChatConfiguration(uiConfiguration: uiConfigurationWithImage) 
  // or   // let chatConfiguration = NowChatConfiguration(uiConfiguration: uiConfigurationWithText)

attachmentUploadButton

AttachmentUploadButton?

UI configuration for the AttachmentUploadButton that is shown next to the text input while talking with a live agent.Call the NowChatConfiguration - AttachmentUploadButton(isVisible: Boolean = true) method to define the value of this parameter.

For example:

JavaScript
let attachmentUploadButton = NowChatConfiguration.AttachmentUploadButton(isVisible: false)let uiConfigurationWithAttachmentButton = NowChatConfiguration.UIConfiguration(attachmentUploadButton: attachmentUploadButton)         
let chatConfiguration = NowChatConfiguration(uiConfiguration: uiConfigurationWithAttachmentButton)

voiceInputButton

VoiceInputButton?

Optional. UI configuration for the speech-to-text microphone button shown in the text input bar.Default: nil (the button is visible)

hideBranding

Boolean

Optional. Flag that indicates whether to hide the ServiceNow branding.Valid values:

  • true: ServiceNow branding is hidden.
  • false: ServiceNow branding is shown.

Default: false

|Type|Description| |----|-----------| |UIConfiguration|Object containing the UI configurations defined in the provided parameters.|

The following code example calls the UIConfiguration() subclass to set the chat UI configuration.

JavaScript
func makeChatScreen() -> UIViewController? {
  let attachmentUploadButton = NowChatConfiguration.AttachmentUploadButton(isVisible: false)
  // Configure close button as image  let buttonImage = UIImage(systemName: "arrow.left.circle") ?? nil
  var closeButtonImage: NowChatConfiguration.CloseButtonType?  if let buttonImage {    closeButtonImage = .image(buttonImage)  }  let uiConfigurationWithImage = NowChatConfiguration.UIConfiguration(closeButton: closeButtonImage, attachmentUploadButton: attachmentUploadButton)         
  let chatConfiguration = NowChatConfiguration(uiConfiguration: uiConfigurationWithImage) 
  let result = chatService.makeChatUI(theme: CarrascoChatTheme(chatColors: ChatColors()), chatConfiguration: chatConfiguration)
  switch result {     case .success(let chatViewController):      return chatViewController    case .failure(let error):      debugPrint("Chat screen creation failed with error: \(error)")      return nil  }}

NowChatConfiguration - VoiceInputButton(isVisible: Bool)

Defines the UI configurations to apply to the speech-to-text microphone button that appears in the text input bar.

VoiceInputButton is a struct of the NowChatConfiguration class.

Name

Type

Description

isVisible

Boolean

Flag that sets the visibility of the speech-to-text microphone button in the text input bar.Valid values:

  • true: The button is visible.
  • false: The button is hidden.
|Type|Description| |----|-----------| |VoiceInputButton|Object containing the UI configuration for the speech-to-text microphone button.|

The following code example hides the speech-to-text microphone button.

JavaScript
func makeChatScreen() -> UIViewController? {  let voiceInputButton = NowChatConfiguration.VoiceInputButton(isVisible: false)  let uiConfigurationWithVoiceInputButton = NowChatConfiguration.UIConfiguration(voiceInputButton: voiceInputButton)
  let chatConfiguration = NowChatConfiguration(uiConfiguration: uiConfigurationWithVoiceInputButton)
  let result = chatService.makeChatUI(theme: CarrascoChatTheme(chatColors: ChatColors()), chatConfiguration: chatConfiguration)
  switch result {    case .success(let chatViewController):      return chatViewController    case .failure(let error):      debugPrint("Chat screen creation failed with error: \(error)")      return nil  }}
Search documentation
Search document titles and file paths on the australia branch