NowChatServiceDelegate protocol - iOS

concept brazil Updated Sep 10, 2026 2 min read NowChatServiceDelegateiOSProtocol.md
Raw file servicenow.com

The NowChatServiceDelegate protocol provides callbacks for notification of actions within the NowChatService such as a request to open a URL or dismiss the chat view controller.

Parent Topic:Mobile SDK - iOS

NowChatServiceDelegate - chatService(_chatService: NowChatService, didRequestOpenUrlurl: URL)

Callback that notifies the host application that the specified chat service received a request to open a URL. This callback is usually triggered by a user tapping on a link in the chat UI. It is the host application's responsibility to handle opening the URL or ignore the request.

Name Type Description
chatService NowChatService NowChatService object making the request.
didRequestOpenUrl url URL URL that the service has requested to open.
Type Description
None

The following code example shows how to call this function.

JavaScript
func chatService(_ chatService: NowChatService, didRequestOpenUrl url: URL) {  var updatedViewState = makeViewState()  updatedViewState.urlToOpen = url  viewState = updatedViewState}

NowChatServiceDelegate - chatService(_ chatService: NowChatService, systemThemeDidChange traitCollection: UITraitCollection)

Callback that notifies the host application that the system chat theme changed.

Name Type Description
chatService NowChatService NowChatService object making the request.
traitCollection UITraitCollection UITraitCollection that contains the new theme.
Type Description
None

The following code example shows how to override the systemThemeDidChange() delegate function to call the updateTheme() function to apply theme changes when the system theme changes.

JavaScript
func chatService(_ chatService: any SnowChat.ChatServiceProvider, systemThemeDidChange traitCollection: UITraitCollection) {
  /// The corresponding updateTheme() method can be called here to change the UI theme based on System Theme  chatService.updateTheme(theme: traitCollection.userInterfaceStyle == .dark ? DarkNowChatTheme() : LightNowChatTheme())  print(“System Theme Did Change)}

NowChatServiceDelegate - chatServiceViewControllerWasDismissed(_chatService: NowChatService)

Callback that notifies the host application that the chat view controller was dismissed.

Name Type Description
chatService NowChatService NowChatService object whose view controller was dismissed.
Type Description
None

The following code example shows how to call this function.

Text
func chatServiceViewControllerWasDismissed(_ chatService: NowChatService) {  resetChat()}

NowChatServiceDelegate - didEndSessionWithId(sessionId: String)

Called when the chat screen is closed and the chat session ends.

Note: You can define the desired functionality for this callback by overriding the function.

Name

Type

Description

sessionId

String

Sys_id of the session that ended.Table: Conversation Session [sys_cs_session]

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

The following code example shows where to place your code to override the default functionality.

JavaScript
func chatService(_ chatService: NowChatService, didEndSessionWithId sessionId: String) {  print("Chat Session ended with ID: \(sessionId)")}
Search documentation
Search document titles and file paths on the brazil branch