> For the complete documentation index, see [llms.txt](https://docs.caf.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.caf.io/sdk-lite/sdk-lite-english-pt-br/configuracao/ios/lifecycle.md).

# Ciclo de vida

## CafFaceLivenessLiteDelegate

O `CafFaceLivenessLiteDelegate` O protocolo trata os principais eventos durante o processo de vivacidade:

| Evento                                                                                      | Descrição                                                                                                                                                                                            |
| ------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `didFinishWithSuccess(livenessResult: CafFaceLivenessLiteResult)`                           | Chamado assim que a captura é concluída; inclui `signedResponse` JWT                                                                                                                                 |
| `didFinishWithFailure(type: CafFailureType, description: String?, signedResponse: String?)` | Chamado quando a captura é concluída sem ser aprovada (iluminação, alinhamento etc.); sempre inclui a sessão `signedResponse`                                                                        |
| `didFinishWithError(type: CafErrorType, description: String)`                               | Chamado em caso de erro de execução (permissão, rede, token etc.). Veja [Tratamento de Erros](/sdk-lite/sdk-lite-english-pt-br/tratamento-de-erros/ios/handling-errors.md) cada tipo e como tratá-lo |
| `cancelled()`                                                                               | Fluxo cancelado pelo usuário                                                                                                                                                                         |
| `loading()`                                                                                 | O SDK começou a aguardar a solicitação de sessão                                                                                                                                                     |
| `loaded()`                                                                                  | O SDK parou de aguardar: emitido quando a solicitação de sessão é concluída e novamente quando o fluxo termina, logo após o callback final                                                           |

`loading()` e `loaded()` são emitidos, independentemente de o `carregamento` opção de `setup` estar ativada. Essa opção apenas mostra ou oculta a tela de carregamento integrada do SDK.

Chamar `startSDK` enquanto uma captura já estiver em andamento é ignorado: nada é apresentado e nenhum método do delegate é chamado.

De **3.0.0**quando uma sessão pré-aquecida é consumida, não há solicitação de sessão para aguardar, então nenhum `loading()` / `loaded()` par é emitido para essa etapa.

De **3.1.0**nenhum `loading()` / `loaded()` par é emitido após a captura, seja como for: o resultado é entregue no momento em que a captura é concluída e a tentativa é registrada. No caminho pré-aquecido, isso significa que o delegate pode nunca receber `loading()` de forma alguma — não confie nisso como um sinal de que a captura começou.

### Exemplo

```swift
import CafFaceLivenessLite

extension YourViewController: CafFaceLivenessLiteDelegate {
    func didFinishWithSuccess(livenessResult: CafFaceLivenessLiteResult) {
        print("Sucesso: \(livenessResult.signedResponse ?? \"-\")")
    }

    func didFinishWithFailure(type: CafFailureType, description: String?, signedResponse: String?) {
        print("Falha: type=\(type) desc=\(description ?? \"-\") signed=\(signedResponse ?? \"-\")")
    }

    func didFinishWithError(type: CafErrorType, description: String) {
        print("Erro: type=\(type) desc=\(description)")
    }

    func cancelled() { print("Cancelado") }
    func loading() { print("Carregando") }
    func loaded() { print("Carregado") }
}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.caf.io/sdk-lite/sdk-lite-english-pt-br/configuracao/ios/lifecycle.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
