---
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


---

# Classe do Now VoiceService - iOS

# Classe do Now VoiceService - iOS {#ariaid-title1}

Versão de lançamento: Brazil  
Atualizado 10 de set. de 2026  
![](https://www.servicenow.com/docs/portal-asset/ico-clock) 4 min. de leitura  
A classe NowVoiceService gerencia sessões do agente de voz para uma única ServiceNow instância.  
Nota:  
Inicialize um Now VoiceService chamando [MakeVoiceService(instanceUrl: URL) lança assíncrona](https://servicenow-prod.fluidtopics.net/ILf0ZNxyU9MmChYWSYCD~w#NVoice-makeVoiceService_S "Cria uma instância do Now VoiceService para a ServiceNow instância especificada.").  
{#NowVoiceServiceiOSAPI__table_vx2_klw_nv1__entry__3}

| Nome | Tipo | Descrição |
|-|-|-|
| configuração | [NowServiceConfiguration](https://servicenow-prod.fluidtopics.net/ccI5ZdteLc~VUh2axpIVJA#NowServiceConfigurationiOSStruct "A estrutura do NowServiceConfiguration define informações de configuração para um serviço de recurso.") | A configuração de serviço da ServiceNow instância. |
| configurações | Matriz de [Now VoiceEndpoints](https://servicenow-prod.fluidtopics.net/DhqWFwbcOFqnSin1VSPx_A "Descreve um endpoint do agente de voz.") | Lista de configurações de endpoint de voz disponíveis recuperadas da instância. |
| IsMutado | Bool | Sinalizador que indica o estado mudo do microfone para a chamada atual. A definição desta propriedade não terá efeito se nenhuma chamada estiver ativa no momento. Valores válidos: * Verdadeiro: O microfone está mudo. * Falso: O microfone não está mudo ou nenhuma chamada está ativa. {#NowVoiceServiceiOSAPI__ul_png_bdk_jkc} |
| Voicenabled | Bool | Sinalizador que indica se a voz está habilitada na instância. Valores válidos: * Verdadeiro: A voz está habilitada. * Falso: A voz está desativada. {#NowVoiceServiceiOSAPI__ul_cq2_w1h_yjc} Sempre `verdadeiro` depois que um NowVoiceService é inicializado com sucesso com [makeVoiceService(instanceUrl:)](https://servicenow-prod.fluidtopics.net/ILf0ZNxyU9MmChYWSYCD~w#NVoice-makeVoiceService_S "Cria uma instância do Now VoiceService para a ServiceNow instância especificada."). |
[Tabela 1. Propriedades]

{#NowVoiceServiceiOSAPI__table_vx2_klw_nv1}

## NowVoiceService - EndCall() {#ariaid-title2}

Termina a chamada de voz atual.
Não tem efeito se nenhuma chamada estiver ativa.
{#NVoiceServ-endCall__table_cs5_2ck_jkc__entry__3}

| Nome | Tipo | Descrição |
|-|-|-|
| Nenhum |   |   |
[Tabela 2. Parâmetros]

{#NVoiceServ-endCall__table_cs5_2ck_jkc} {#NVoiceServ-endCall__table_qft_qzv_nva8__entry__2}

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

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

    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 button
    voiceService?.endCall()

## NowVoiceService - hasActiveCall() {#ariaid-title3}

Verifica se há uma chamada de voz ativa no momento.
{#NVoiceServ-hasActiveCall__table_cs5_2ck_jkc__entry__3}

| Nome | Tipo | Descrição |
|-|-|-|
| Nenhum |   |   |
[Tabela 4. Parâmetros]

{#NVoiceServ-hasActiveCall__table_cs5_2ck_jkc} {#NVoiceServ-hasActiveCall__table_qft_qzv_nva8__entry__2}

| Tipo | Descrição |
|-|-|
| Booliano | Sinalizador que indica se há uma chamada de voz ativa. Valores válidos: * Verdadeiro: Há uma chamada de voz ativa. * Falso: Não há uma chamada de voz ativa. {#NVoiceServ-hasActiveCall__ul_qs4_pbk_jkc} |
[Tabela 5. Retorna]

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

    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 call
    if voiceService?.hasActiveCall() == true {
        // A voice call is currently in progress
    }

## NowVoiceService - startVoice(endpoint: NowVoiceEndpoint, uiConfiguration: NowVoiceUIConfiguration, retornos de chamada: NowVoiceCallbacks, tema: NowVoiceThemeable) lançamentos assíncronos {#ariaid-title4}

Cria um UIViewController que contém a IU do agente de voz, pronta para ser apresentada em um modal.
O UIViewController gerencia o ciclo de vida completo da sessão de voz, incluindo a desmontagem na demissão.

Esta função busca um token de acesso OAuth automaticamente antes de iniciar a IU de voz.
{#NVoiceServ-startVoice_O_O_O_O__table_pft_qzv_nvo2__entry__3}

| Nome | Tipo | Descrição |
|-|-|-|
| endpoint | [NowVoiceEndpoint](https://servicenow-prod.fluidtopics.net/DhqWFwbcOFqnSin1VSPx_A "Descreve um endpoint do agente de voz.") | O canal do agente de voz ao qual se conectar. Obtenha do [`Now VoiceService.configurations`](https://servicenow-prod.fluidtopics.net/RTK9OxI~_wt28ycLLYR55A#NowVoiceServiceiOSAPI "A classe NowVoiceService gerencia sessões do agente de voz para uma única ServiceNow instância."). Os endpoints são recuperados das ServiceNowMobile SDK configurações da sua instância. |
| UIConfiguration | [NowVoiceUIConfiguration](https://servicenow-prod.fluidtopics.net/BRwqQA2Ir4Sb2xH3xYTsYw#NowVoiceUIConfigiOSStruct "Especifica opções de apresentação para a IU do agente de voz.") | Opcional. Opções de apresentação para a IU do agente de voz. Se omitido, usa os valores padrão para NowVoiceUIConfiguration. |
| retornos de chamada | [NowVoiceCallbacks](https://servicenow-prod.fluidtopics.net/g68KOe9jRGCszXPhMJ~WtA#NowVoiceCallbacksiOSStruct "Especifica retornos de chamada para o ciclo de vida da sessão de voz e eventos de conteúdo.") | Opcional. Retornos de chamada para eventos de sessão de voz. Se omitido, os eventos serão ignorados silenciosamente. |
| tema | [NowVoiceThemeable](https://servicenow-prod.fluidtopics.net/LTCons4s1bbcV~6Pej~68Q "Define as cores a serem aplicadas aos elementos de IU do NowVoice.") | Opcional. O tema visual aplicado à IU de voz. Padrão: [`NowVoiceDefaultTheme`](https://servicenow-prod.fluidtopics.net/0DnyO74yOkFFW0lMKzYoAw#NVoiceDefThemeiOSStruct "A implementação padrão do NowVoiceThemeable.") |
[Tabela 6. Parâmetros]

{#NVoiceServ-startVoice_O_O_O_O__table_pft_qzv_nvo2} {#NVoiceServ-startVoice_O_O_O_O__table_qft_qzv_nvo2__entry__2}

| Tipo | Descrição |
|-|-|
| UIViewController | Um UIViewController que contém a interface do agente de voz de tela cheia. Apresente-o em um modal. Defina `modalPresentationStyle como .fullscreen` para a experiência pretendida. |
[Tabela 7. Retorna]

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

    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 UI
    let 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 modal
    vc.modalPresentationStyle = .fullScreen
    present(vc, animated: true)

## NowVoiceService - toggleMute() {#ariaid-title5}

Alterna o estado mudo do microfone da chamada atual.
{#NVoiceServ-toggleMute__table_cs5_2ck_jkc__entry__3}

| Nome | Tipo | Descrição |
|-|-|-|
| Nenhum |   |   |
[Tabela 8. Parâmetros]

{#NVoiceServ-toggleMute__table_cs5_2ck_jkc} {#NVoiceServ-toggleMute__table_qft_qzv_nva7__entry__2}

| Tipo | Descrição |
|-|-|
| Bool | Sinalizador que indica o novo estado mudo do microfone para a chamada atual. Valores válidos: * Verdadeiro: O microfone agora está mudo. * Falso: O microfone agora não está mudo ou nenhuma chamada está ativa. {#NVoiceServ-toggleMute__ul_png_bdk_jkc} |
[Tabela 9. Retorna]

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

    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 backgrounding
    voiceService?.toggleMute()

    // Check mute state to update a custom mute button icon
    let muted = voiceService?.isMuted ?? false

## NowVoiceService - updateTheme(theme: NowVoiceThemeable) {#ariaid-title6}

Atualiza o tema visual da IU de voz ativa no momento.
Esta função não terá efeito se nenhuma sessão de voz estiver ativa no momento. Para aplicar um tema visual na inicialização da sessão de voz, forneça um tema ao chamar [startVoice(endpoint:uiConfiguration:callbacks:theme:)](https://servicenow-prod.fluidtopics.net/RTK9OxI~_wt28ycLLYR55A#NVoiceServ-startVoice_O_O_O_O "Cria um UIViewController que contém a IU do agente de voz, pronta para ser apresentada em um modal.").
{#NVoiceServ-updateTheme_O__table_pft_qzv_nvo3__entry__3}

| Nome | Tipo | Descrição |
|-|-|-|
| tema | NowVoiceThemeable | O tema a ser aplicado à IU de voz ativa. |
[Tabela 10. Parâmetros]

{#NVoiceServ-updateTheme_O__table_pft_qzv_nvo3} {#NVoiceServ-updateTheme_O__table_qft_qzv_nvo2__entry__2}

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

{#NVoiceServ-updateTheme_O__table_qft_qzv_nvo2}  
O exemplo de código a seguir atualiza o tema visual da IU de voz ativa no momento.

    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 active
    voiceService?.updateTheme(theme: MyVoiceTheme())


