TuIdentidadSDK iOS SDK v1.1.5

This library makes it possible to capture two images "INE Front" and "INE Back", which correspond to the two sides of the voter's credential. Likewise, it is possible to capture a frontal image of the “Proof of address CFE”; send them to TuIdentidadSDK to verify the captured documents and issue the result. This document is specifically aimed at technical level users who require information about the TuIdentidad SDK “TuIdentidadSDK”.

Requirements

XCode 11.2.1
IOS 10+
Arquitectura -armv7, arm64
CocoaPods

Project overview

Restrictions and assumptions

1) Cocoapods is used as the manager of this framework.

Previous clarifications

1) The Apikey must be requested with the provider.

Development

TuIdentidadSDK (IOS) was developed in Swift 5 and Xcode 11.2.1.

Cocoapods installation

1) If you are using the default version of Ruby on your Mac, you will have to use the sudo command.

$ gem install cocoapods
$ sudo gem install cocoapods

2) Enter the username and password credentials, this will raise the privileges of the "install" command and allow you to put the files in a protected folder.

Start using Cocoapods with TuIdentidadSDK

AlamoFire helps HTTP requests in Swift.

1) You need an Xcode project to start. Create a project or use an existing one.
2) Close your Xcode project, while Cocoapods is going to make changes to the project.
3) Open the terminal to the location of the folder that belongs to your Xcode project.
4) Enter pod init in the terminal.

$ pod init

Download framework

The text "TuIdentidadSDKDemo" is the name of the solution, the example shown below is the configuration file, necessary to download the framework.

# Uncomment the next line to define a global platform for your project  
platform :ios, '10.0'  
target 'TuIdentidadSDKDemo' do  
# Comment the next line if you don't want to use dynamic frameworks
use_frameworks!
#TuIdentidad SDKs
  #SDK INE  
  pod 'TuIdentidadSDK', '~>1.1.5'
  #SDK ADDRES
  pod 'TuIdentidadSDK/AddressKit', '~>1.1.5'
end  

1) Run the Cocoapods installer, it will take some time if it is the first time you install it:

$ pod install

2) Depending on how old your installation is, you may need to use the update command to get the current version. In case you happen to see the following error, check out the Fix problems section below.

Fix problems with Cocoapods

1) Try clearing the cache before you start.
2) Update Cocoapods or try reinstalling it.

Privacy configuration

Add the description of the NSCameraUsageDescription key ("Privacy - Camera Usage Description") in your info.plist file.
ex. 'This app use the camera to validate documents with pictures.'

Using TuIdentidadSDK

1) Import the TuIdentidadSDK library.

import TuIdentidadSDK

2) Call the delegate to get the validation result.

class ViewController: UIViewController, IDValidationDelegate

3) Delegate function where the result of the validation is obtained. INE method and corresponding IDVAL.

TUID.instantiateIDAuth(delegate: self, context: self, apikey: "Your-Api-Key", method: .INE, showResults: false, validateOptions: IDValidateOptions(checkInfo: true, checkQuality: true, checkPatterns: true, checkCurp: true, checkFace: true))
TUID.instantiateTuIdentidadSDK(delegate:self ,context: self, apikey: "Your-Api-Key”, method:
.IDVAL, showResults: false)

4) This function returns the result of the validation, it is a function built into the delegate.

// IDVAL and OnlyOCR delegate 
func getData(data: IDValidation) {  
    print(data)  
}  
// INE Method delegate  
func getINEData(data: IDValidationINE) {  
    debugPrint(data)  
}  
func error(response: String) {  
    debugPrint(response)  
}  

TuIdentidadSDK properties

delegate: The delegate is sent, which in this case would be the controller so that this view listens when the SDK obtains the results.
context: The context is sent from where the cell phone is sent to call.
apikey: Necessary to consume the API of TuIdentidadSDK (request activation with provider).

method: The SDK has two INE processing methods:

a) IDVAL: returns OCR + validation of the INE. b) ONLYOCR: returns the OCR, without validation of the INE.
c) INE: New and improved INE + OCR validation service.

showResults: Boolean that indicates whether to show a viewController with the results. (Discontinued).

validateOptions: Validation options for the identification. It is recommended to put the values of 'checkInfo', 'checkQuality', 'checkPatterns' in 'true'. ‘CheckCurp’ only in case of consuming the CURP validation service identified in the document before RENAPO and 'checkFace' in case it is not required to validate the photograph of the person, default value 'true'.

SDK usage example

import UIKit  
import TuIdentidadSDK  
class ViewController: UIViewController, IDValidationDelegate {  
    override func viewDidLoad() {  
        super.viewDidLoad()  
        // Do any additional setup after loading the view.  
    }  
    override func viewDidAppear(_ animated: Bool) {  
        super.viewDidAppear(animated)  
        TUID.instantiateIDAuth(delegate: self, context: self, apikey: "Your-Api-Key", method: .INE, showResults: false, validateOptions: IDValidateOptions(checkInfo: true, checkQuality: true, checkPatterns: true, checkCurp: true, checkFace: true))  
    }  
    // MARK - TuIdentidadSDKDelegate  
    func getData(data: IDValidation) {  
        debugPrint(data)  
    }  
    func getINEData(data: IDValidationINE) {  
        debugPrint(data)  
    }  
    func error(response: String) {  
        debugPrint(response)  
    }
}

Using TuIdentidadSDK/AddressKit (TuIDAddressKit)

1) Import TuIdentidadSDK library:

import TuIdentidadSDK

2) Implement the IDAddressDocumentDelegate protocol.

class AddressViewController: UIViewController, IDAddressDocumentDelegate

3) Present the controller for the validation of proof of residence documents.

@IBAction func didValidateIdTouchUpInside(_ sender: Any) {  
    let idAddressViewController = IDAddressViewController()
    idAddressViewController.delegate = self
    idAddressViewController.apiKey = "Your-Api-Key"
    self.present(idAddressViewController, animated: true, completion: nil)
}

The controller returns the result of the validation, it is a function built into the delegate.

    func addressDocumentController(controller: IDAddressViewController, didFinishWithResponse response:   IDAddressDocumentResponse, andImage image: UIImage) {  
        debugPrint(response.valid)  
        debugPrint(response.data)  
    }

    func addressDocumentController(controller: IDAddressViewController, didFinishWithError error: IDErrorResponse, andImage image: UIImage) {  
        debugPrint(error.message)  
        debugPrint(error.code)  
    } 

TuIDAddressKit properties

delegate: The delegate is sent, which in this case would be the controller so that this view listens when the SDK obtains the results.
apikey: Necessary to consume the API of TuIdentidadSDK (request activation with provider).

Example of use of TuIDAddressKit

import UIKit  
import TuIdentidadSDK  
class AddressViewController: UIViewController, IDAddressDocumentDelegate {  
    @IBAction func didValidateIdTouchUpInside(_ sender: Any) {  
        let idAddressViewController = IDAddressViewController()  
        idAddressViewController.delegate = self  
        idAddressViewController.apiKey = "Your-Api-Key"  
        self.present(idAddressViewController, animated: true, completion: nil)  
    }  
    // MARK: - IDAddressDocumentDelegate  
    func addressDocumentController(controller: IDAddressViewController, didFinishWithResponse response:  IDAddressDocumentResponse, andImage image: UIImage) {  
        debugPrint(response.valid)  
        debugPrint(response.data)  
    }  
    func addressDocumentController(controller: IDAddressViewController, didFinishWithError error: IDErrorResponse, andImage image: UIImage) {  
        debugPrint(error.message)  
        debugPrint(error.code)  
    }
}