---
sourceDocument: Referência de API do Brasil
sourceDocumentLink: https://servicenow-prod.fluidtopics.net/r/pt-BR/api-reference

 Release :

    - brazil

ft:locale :

    - pt-BR

ft:publication_title :

    - Referência de API do Brasil

ft:clusterId :

    - crapiref

bundleId :

    - crapiref

workflow :

    - Creator


---

# Protocolo NowChatServiceDelegate - iOS

# Protocolo NowChatServiceDelegate - iOS {#ariaid-title1}

Versão de lançamento: Brazil  
Atualizado 10 de set. de 2026  
![](https://www.servicenow.com/docs/portal-asset/ico-clock) 2 min. de leitura  
O protocolo NowChatServiceDelegate fornece retornos de chamada para notificação de ações dentro do NowChatService , como uma solicitação para abrir uma URL ou descartar o controlador de exibição de bate-papo.

## NowChatServiceDelegate - chatService(_chatService: NowChatService, didRequestOpenUrlurl: URL) {#ariaid-title2}

Retorno de chamada que notifica a aplicação host de que o serviço de bate-papo especificado recebeu uma solicitação para abrir um URL. Este retorno de chamada geralmente é acionado por um usuário tocando em um link na IU do bate-papo. É responsabilidade da aplicação host lidar com a abertura da URL ou ignorar a solicitação.
{#NCSD-chatService_O_S__table_alb_31w_wqb__entry__3}

| Nome | Tipo | Descrição |
|-|-|-|
| ChatService | [NowChatService](https://servicenow-prod.fluidtopics.net/k0ZJjQfOanf6fNNQoPFfJA#NowChatServiceiOSAPI "A classe NowChatService fornece Atendente capacidades virtuais e de bate-papo.") | Objeto NowChatService que está fazendo a solicitação. |
| url didRequestOpenUrl | URL | URL que o serviço solicitou para abrir. |
[Tabela 1. Parâmetros]

{#NCSD-chatService_O_S__table_alb_31w_wqb} {#NCSD-chatService_O_S__table_blb_31w_wqb__entry__2}

| Tipo | Descrição |
|-|-|
| Nenhum(a) |   |
[Tabela 2. Retorna]

{#NCSD-chatService_O_S__table_blb_31w_wqb}  
O exemplo de código a seguir mostra como chamar esta função.

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

## NowChatServiceDelegate - chatService(_ chatService: NowChatService, systemThemeDidChange traitCollection: UITraitCollection) {#ariaid-title3}

Retorno de chamada que notifica a aplicação host de que o tema de bate-papo do sistema foi alterado.
{#NCSD-chatService_O_B_O__table_uhw_s1w_x2c__entry__3}

| Nome | Tipo | Descrição |
|-|-|-|
| ChatService | [NowChatService](https://servicenow-prod.fluidtopics.net/k0ZJjQfOanf6fNNQoPFfJA#NowChatServiceiOSAPI "A classe NowChatService fornece Atendente capacidades virtuais e de bate-papo.") | Objeto NowChatService que está fazendo a solicitação. |
| TraitCollection | [UITraitCollection](https://developer.apple.com/documentation/uikit/uitraitcollection) | UITraitCollection que contém o novo tema. |
[Tabela 3. Parâmetros]

{#NCSD-chatService_O_B_O__table_uhw_s1w_x2c} {#NCSD-chatService_O_B_O__table_vhw_s1w_x2c__entry__2}

| Tipo | Descrição |
|-|-|
| Nenhum(a) |   |
[Tabela 4. Retorna]

{#NCSD-chatService_O_B_O__table_vhw_s1w_x2c}  
O exemplo de código a seguir mostra como substituir a função delegada systemThemeDidChange() para chamar a função updateTheme() para aplicar mudanças de tema quando o tema do sistema mudar.

    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 - chatServiceViewControllerWasDismisst(_chatService: NowChatService) {#ariaid-title4}

Retorno de chamada que notifica a aplicação host de que o controlador de exibição de bate-papo foi descartado.
{#NCSD-chatServiceViewContDismiss_O__table_vs4_qbw_wqb__entry__3}

| Nome | Tipo | Descrição |
|-|-|-|
| ChatService | [NowChatService](https://servicenow-prod.fluidtopics.net/k0ZJjQfOanf6fNNQoPFfJA#NowChatServiceiOSAPI "A classe NowChatService fornece Atendente capacidades virtuais e de bate-papo.") | Objeto NowChatService cujo controlador de exibição foi descartado. |
[Tabela 5. Parâmetros]

{#NCSD-chatServiceViewContDismiss_O__table_vs4_qbw_wqb} {#NCSD-chatServiceViewContDismiss_O__table_ws4_qbw_wqb__entry__2}

| Tipo | Descrição |
|-|-|
| Nenhum(a) |   |
[Tabela 6. Retorna]

{#NCSD-chatServiceViewContDismiss_O__table_ws4_qbw_wqb}  
O exemplo de código a seguir mostra como chamar esta função.

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

## NowChatServiceDelegate - didEndSessionWithId(SessionId: Cadeia de caracteres) {#ariaid-title5}

Chamado quando a tela de bate-papo é fechada e a sessão de bate-papo termina.
Nota:  
Você pode definir a funcionalidade desejada para este retorno de chamada substituindo a função.
{#NCSD-didEndSessionWId_S__table_j1t_hv2_52c__entry__3}

| Nome | Tipo | Descrição |
|-|-|-|
| SessionId | Cadeia de caracteres | Sys_id da sessão encerrada. Tabela: Sessão de conversa \[sys_cs_session\] |
[Tabela 7. Parâmetros]

{#NCSD-didEndSessionWId_S__table_j1t_hv2_52c} {#NCSD-didEndSessionWId_S__table_k1t_hv2_52c__entry__2}

| Tipo | Descrição |
|-|-|
| Nenhum(a) |   |
[Tabela 8. Retorna]

{#NCSD-didEndSessionWId_S__table_k1t_hv2_52c}  
O exemplo de código a seguir mostra onde colocar seu código para substituir a funcionalidade padrão.

    func chatService(_ chatService: NowChatService, didEndSessionWithId sessionId: String) {
      print("Chat Session ended with ID: \(sessionId)")
    }


