---
title: Document capture
canonical: https://developer.unico.io/dual-api/developer/sdks-and-tools/ios-sdk/document-capture/
locale: en
generated_by: markdown-export
---

Capture of identity documents. The SDK presents a frame to assist the user in positioning the document; after positioning, the user clicks the button to capture the photo.

:::warning[No content validation]
The SDK does not perform any type of validation on what is being captured.
:::

## Available document frames

| Frame | Description |
|---|---|
| `DocumentEnums.CPF` | Capture the CPF |
| `DocumentEnums.CNH` | Capture the open CNH |
| `DocumentEnums.cnhFrente` | Capture the front of the CNH |
| `DocumentEnums.cnhVerso` | Capture the back of the CNH |
| `DocumentEnums.RG` | Capture the open RG |
| `DocumentEnums.rgFrente` | Capture the front of the RG |
| `DocumentEnums.rgVerso` | Capture the back of the RG |
| `DocumentEnums.none` | Generic rectangular frame for any other document |

:::tip[Generic frame]
If you need to capture a document for which there is no specific frame (e.g., RNE), use `DocumentEnums.none` — a generic, rectangular frame that can be used to guide any capture.
:::

For the full list of supported document types, see [API Reference > Enums](/developers/sdks-and-tools/ios/api-reference/enums).

## Starting a document capture

****Step 2** — Implement `DocumentCameraDelegate` and `AcessoBioDocumentDelegate`**

These delegates handle the document capture result callbacks:

  | Method | Description |
  |---|---|
  | `onSuccessDocument(result)` | Capture succeeded — returns `DocumentResult` with `base64` (preview) and `encrypted` (JWT for the API) |
  | `onErrorDocument(errorBio)` | Capture failed — returns an `ErrorBio` with code and description |

  ### Swift

    ```swift
    class ViewController: UIViewController, AcessoBioManagerDelegate,
      DocumentCameraDelegate, AcessoBioDocumentDelegate {

      func onSuccessDocument(_ result: DocumentResult!) { }
      func onErrorDocument(_ errorBio: ErrorBio!) { }
    }
    ```

### Objective-C

    ```objectivec
    // .h
    @interface ViewController: UIViewController <AcessoBioManagerDelegate,
      DocumentCameraDelegate, AcessoBioDocumentDelegate> {
      AcessoBioManager *unicoCheck;
    }

    // .m
    - (void)onSuccessDocument:(DocumentResult *)result {
        NSLog(@"%@", result.base64);
    }

    - (void)onErrorDocument:(ErrorBio *)errorBio { }
    ```

****Step 3** — Call `prepareDocumentCamera` and `openDocument`**

Call `prepareDocumentCamera` passing the SDK config. When the camera is ready, `onCameraReadyDocument` is triggered with an `AcessoBioCameraOpenerDelegate` — open the camera using `openDocument()` and pass the desired `DocumentEnums`:

  - `onCameraReadyDocument(cameraOpener)` — camera is ready; call `openDocument(.CNH, delegate: self)`.
  - `onCameraFailedDocument(message)` — camera preparation failed (`ErrorPrepare` is an extension of `ErrorBio`).

  ### Swift

    ```swift
    @IBAction func openCamera(_ sender: Any) {
      unicoCheck.build().prepareDocumentCamera(self, config: YourUnicoConfigClass())
    }

    func onCameraReadyDocument(_ cameraOpener: AcessoBioCameraOpenerDelegate!) {
      cameraOpener.openDocument(DocumentEnums.CNH, delegate: self)
    }

    func onCameraFailedDocument(_ message: ErrorPrepare!) { }
    ```

### Objective-C

    ```objectivec
    - (IBAction)openCamera:(UIButton *)sender {
        [[unicoCheck build] prepareDocumentCamera:self config:[YourUnicoConfigClass new]];
    }

    - (void)onCameraReadyDocument:(id)cameraOpener {
        [cameraOpener openDocument:DocumentCNH delegate:self];
    }

    - (void)onCameraFailedDocument:(ErrorPrepare *)message { }
    ```

For the full result handling, see [Receiving the result](/developers/sdks-and-tools/ios/capture-flow/receiving-the-result).