> 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/caf-sdk/caf-sdk-pt-br/ios/standalone-modules/caffaceauth/start-sdk.md).

# Iniciar o SDK

### Instanciando o SDK

Primeiro, instancie um objeto do tipo `CafFaceAuthSDK`. Este objeto é para você configurar todas as suas regras de negócio:

```swift
class CafFaceAuthViewController: UIViewController {
    var faceAuthenticator: FaceAuthSDK?

    func setupFaceAuthenticator() {
        faceAuthenticator = FaceAuthSDK.Builder()
        // a tabela abaixo mostra todas as opções de configuração do SDK
        .build()
        faceAuthenticator?.delegate = self
    }

    func startFaceAuthenticator() {
        faceAuthenticator?.startFaceAuthSDK(viewController: self, mobileToken:"yourMobileToken", personId: "personId")
    }
}
```

### Obtendo os Resultados

Você deve implementar a `FaceAuthSDKDelegate` classe para obter os resultados do SDK. Para isso, você deve fornecer um `UIViewController` à sua instância do SDK:

```swift
faceAuthenticator?.delegate = self
```

#### Implementação do Delegate

O delegate abaixo deve ser implementado para tratar os resultados do SDK. Ao implementar a extensão do delegate, você terá acesso a um objeto dependendo do tipo de retorno. Em cada caso, o objeto carrega informações diferentes.

```swift
extension FaceAuthViewController: FaceAuthSDKDelegate {
  func didFinishSuccess(with faceAuthenticatorResult: CafFaceAuth.FaceAuthenticatorResult) {
    //tratar o resultado de sucesso
  }
    
  func didFinishWithError(with faceAuthenticatorErrorResult: CafFaceAuth.FaceAuthenticatorErrorResult) {
    //tratar o resultado de erro
  }
    
  func didFinishFaceAuthWithCancelled() {
    //tratar quando o usuário fecha o SDK
  }
    
  func openLoadingScreenStartSDK() {
    //tratar tela de carregamento - exibir
  }
    
  func closeLoadingScreenStartSDK() {
    //tratar tela de carregamento - fechar
  }
    
  func openLoadingScreenValidation() {
    //tratar tela de carregamento - exibir
  }
    
  func closeLoadingScreenValidation() {
    //tratar tela de carregamento - fechar
  }
}   
```

#### Tela de Carregamento

Para criar uma tela de carregamento durante os processos de validação do SDK, você precisa implementar uma view com a tela de carregamento e exibi-la nas *abertas* e *fechar* funções do delegate. `openLoadingScreenStartSDK()`, `closeLoadingScreenStartSDK()`, `openLoadingScreenValidation()`, `closeLoadingScreenValidation()`

Na implementação do SDK, é necessário adicionar a view à pilha de views usando o código a seguir. Isso torna a view visível.

```swift
view.addSubview(loadingHUD)
```

Esta view deve ser adicionada antes do Builder do SDK.


---

# 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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.caf.io/caf-sdk/caf-sdk-pt-br/ios/standalone-modules/caffaceauth/start-sdk.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
