> For the complete documentation index, see [llms.txt](https://docs.recognito.vision/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.recognito.vision/id-document-recognition-sdk/integration-guide/ios/sample-application.md).

# Sample Application

{% file src="/files/TagauudjcRdk0n0C7CCO" %}

## Build Project

### - Download and Open Project

* Download [**IDCardRecognition-iOS.zip \[147M\]**](https://www.dropbox.com/scl/fi/fb9xeu6l6uetinceabdil/IDCardRecognition-iOS.zip?rlkey=02g8miakb0op9jg1vjajjgjas\&st=uy1od0s9\&dl=0)
* Open the `IDCardRecognition-iOS` project in Xcode.

### - Setting Up SDK License Key

* Add License key:

{% code title="ViewController.swift" lineNumbers="true" %}

```swift
var ret = IDSDK.setActivation("QbxKmXkM8E2X+CzScRgJZlVxWxIlQL5Scimac/QMNoCeCEzEyCbrIdd0rKU09QO5Zz9/NiSGk0xd" +
     "T5TmKuLIAiwiac1GmOcF6yRH8+FeCfLAlX2yoyUI3EuXxgiJ9T+ZQD+y6cW9wOlO5vRxPtPD4H3t" +
     "xTXkgrUzvKvMNI3e+08jfb7WfJ0VTaL3qzcZtQa9btQT1bNl2baUrWlA5W08P8GETFJq4mjHHusQ" +
     "GUGx4a4OF78Rs2S3lbMs9XoeKy+aJEET/rPiubCf7Br1hytmYg9CDi+3mtdewL+6OCzWVntdKL4h" +
     "IRqd+LAWqGgBYbiVzM9lstNiqCuvDE0bJ4Fn0w==")
```

{% endcode %}

* Build Project.

### - Integration Guide

* Activate and Initialize ID SDK

```swift
override func viewDidLoad() {
    super.viewDidLoad()
    // Do any additional setup after loading the view.
    
    var ret = IDSDK.setActivation("QbxKmXkM8E2X+CzScRgJZlVxWxIlQL5Scimac/QMNoCeCEzEyCbrIdd0rKU09QO5Zz9/NiSGk0xd" +
                       "T5TmKuLIAiwiac1GmOcF6yRH8+FeCfLAlX2yoyUI3EuXxgiJ9T+ZQD+y6cW9wOlO5vRxPtPD4H3t" +
                       "xTXkgrUzvKvMNI3e+08jfb7WfJ0VTaL3qzcZtQa9btQT1bNl2baUrWlA5W08P8GETFJq4mjHHusQ" +
                       "GUGx4a4OF78Rs2S3lbMs9XoeKy+aJEET/rPiubCf7Br1hytmYg9CDi+3mtdewL+6OCzWVntdKL4h" +
                       "IRqd+LAWqGgBYbiVzM9lstNiqCuvDE0bJ4Fn0w==")
    print("set activation: ", ret)
    if(ret == SDK_SUCCESS.rawValue) {
        ret = IDSDK.initSDK()
        print("init sdk: ", ret)
    }

}
```

* Extract Data from Camera Frame

```swift
func captureOutput(_ output: AVCaptureOutput, didOutput sampleBuffer: CMSampleBuffer, from connection: AVCaptureConnection) {
    if(self.cameraRunning == false) {
        return
    }
    
    if(Date().timeIntervalSince1970 - startTime <= 1) {
        return
    }

    guard let pixelBuffer: CVPixelBuffer = CMSampleBufferGetImageBuffer(sampleBuffer) else { return }
           
    CVPixelBufferLockBaseAddress(pixelBuffer, CVPixelBufferLockFlags.readOnly)
    let image = CIImage(cvPixelBuffer: pixelBuffer).oriented(CGImagePropertyOrientation.right)
    
    let context = CIContext(options: nil)
    guard let cg = context.createCGImage(image, from: image.extent) else {
        CVPixelBufferUnlockBaseAddress(pixelBuffer, CVPixelBufferLockFlags.readOnly)
        return
    }

    let capturedImage = UIImage(cgImage: cg, scale: 1.0, orientation: .upMirrored).fixOrientation()
    CVPixelBufferUnlockBaseAddress(pixelBuffer, CVPixelBufferLockFlags.readOnly)
    
    let result = IDSDK.idcardRecognition(capturedImage) as NSDictionary
```

***

## Application UI

<div><figure><img src="/files/0CDGdTgvbxG0cNGTcGgu" alt=""><figcaption></figcaption></figure> <figure><img src="/files/YzlW7k3Z0gXrDVuz0GGY" alt=""><figcaption></figcaption></figure> <figure><img src="/files/oKUmrWr5tstkiflQxtM8" alt=""><figcaption></figcaption></figure> <figure><img src="/files/Ni41YzT8C4yAyS6R0xfR" alt=""><figcaption></figcaption></figure> <figure><img src="/files/0WfHEBKDnM43uWSkNvQ7" alt=""><figcaption></figcaption></figure> <figure><img src="/files/EWOmr2WXEfwTvAmCPKnM" alt=""><figcaption></figcaption></figure></div>


---

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

```
GET https://docs.recognito.vision/id-document-recognition-sdk/integration-guide/ios/sample-application.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
