Skip to main content

IOS SDK Migration

Amani Core SDK Initialization


class AmaniInitializaion: UIViewController {
let amani = Amani.sharedInstance

override func viewDidLoad() {
super.viewDidLoad()

amani.initAmani(
server: "ServerURL",
token: "Token",
customer: CustomerRequestModel.init(idCardNumber: "55555"))
[weak self] { customerModel, error in
print("\(customerModel), \(error)")
}
}
}


NOTE

Amani Delegate is available for use starting from Amani SDK v3.0.0 and later.

In versions below v3.0.0, delegate such as status returned as a result of document upload could be listened to once by the callback in the upload method of the relevant module. Amani Delegate replaces this structure and offers the opportunity to listen to delegate coming from the web socket in more detail.


ID Module

class IDcaptureModule: UIViewController {

let amaniIDCapture = Amani.sharedInstance.IdCapture()
var idCaptureView: UIView? = UIView()

override func viewDidLoad() {
super.viewDidLoad()

amaniIDCapture.setType(type: "XXX_ID_0")

do {
self.idCaptureView = try amaniIDCapture.start(stepId: steps.front.rawValue) { previewImage in
print(previewImage)
}

DispatchQueue.main.async {
self.view.addSubview(self.idCaptureView!)
}

DispatchQueue.main.async {
self.idCaptureView!.removeFromSuperview()
}


amaniIDCapture.upload(location: nil) { uploadSuccess, error in
print(uploadSuccess, error)
}

}catch {
print(error)
}
}
}

NFC Module with IDCapture

class IDcaptureModule: UIViewController {

let amaniIDCapture = Amani.sharedInstance.IdCapture()
var idCaptureView: UIView? = UIView()

override func viewDidLoad() {
super.viewDidLoad()

amaniIDCapture.setType(type: "XXX_ID_0")
//You should take front and back side of ID's. Than you can set startNFC function.
do {
self.idCaptureView = try amaniIDCapture.start(stepId: steps.front.rawValue) { previewImage in
print(previewImage)
}

DispatchQueue.main.async {
self.view.addSubview(self.idCaptureView!)
}

DispatchQueue.main.async {
self.idCaptureView!.removeFromSuperview()
}

amaniIDCapture.startNFC { isMrzRead in
print(isMrzRead)
}

amaniIDCapture.upload(location: nil) { uploadSuccess, error in
print(uploadSuccess, error)
}

}catch {
print(error)
}
}
}

Selfie Module

class SelfieModule: UIViewController {
let amaniSelfie = Amani.sharedInstance.selfie()
var selfieView: UIView? = UIView()

override func viewDidLoad() {
super.viewDidLoad()


do {
amaniSelfie.setType(type: "XXX_SE_0")
self.selfieView = try amaniSelfie.start(completion: { previewImage in
print(previewImage)
})

DispatchQueue.main.async {
self.view.addSubview(self.selfieView!)
}

DispatchQueue.main.async {
self.selfieView!.removeFromSuperview()
}

amaniSelfie.upload(location: nil) { uploadSuccess, error in
print(uploadSuccess, error)
}
}catch {
print(error)
}
}
}

Auto Selfie Module


class AutoSelfieModule: UIViewController {
let amaniAutoSelfie = Amani.sharedInstance.autoSelfie()
var autoSelfieView: UIView? = UIView()

override func viewDidLoad() {
super.viewDidLoad()

amaniAutoSelfie.setType(type: "XXX_SE_0")
do {
self.autoSelfieView = try amaniAutoSelfie.start { previewImage in
print(previewImage)
}

amaniAutoSelfie.upload(location: nil) { uploadSuccess, error in
print(uploadSuccess, error)
}
}catch {
print(error)
}

}
}

Manuel Selfie Module


class ManuelSelfieModule: UIViewController {
let manuelSelfie = Amani.sharedInstance.Selfie()
var manuelSelfieView: UIView? = UIView()

override func viewDidLoad() {
super.viewDidLoad()

manuelSelfie.setType(type: "XXX_SE_0")
do {
self.manuelSelfieView = try manuelSelfie.start { previewImage in
print(previewImage)
}

manuelSelfie.upload(location: nil) { uploadSuccess, error in
print(uploadSuccess, error)
}
}catch {
print(error)
}
}
}

PoseEstimation Module

class PoseEstimationModule: UIViewController {
let amaniPoseEstimation = Amani.sharedInstance.poseEstimation()

override func viewDidLoad() {
super.viewDidLoad()

do {
amaniPoseEstimation.setType(type: "XXX_SE_0")

guard let view: UIView = try amaniPoseEstimation.start(stepId: 0, completion: { previewImage in
print(previewImage)
})else {
return
}
amaniPoseEstimation.upload(location: nil) { uploadSuccess, error in
print(uploadSuccess, error)
}
} catch {
print(error)
}
}
}

NFC Module

class NFCModule: UIViewController {
let amaniScanNFC = Amani.sharedInstance.scanNFC()

override func viewDidLoad() {
super.viewDidLoad()

do {
amaniScanNFC.setType(type: "XXX_NF_0")
let nviData = NviModel(documentNo: "DOCUMENT NO IN ALL CAPS", dateOfBirth: "YYMMDD", dateOfExpire: "YYMMDD")

try amaniScanNFC.start(nviData: nviData) { nfcRequest, error in
print(nfcRequest, error)
}
} catch {

}
}
}

Signature Module

class SignatureModule: UIViewController {
let signature = Amani.sharedInstance.signature()
var signatureView: UIView? = UIView()

override func viewDidLoad() {
super.viewDidLoad()

do {
self.signatureView = try signature.start(stepId: 2) { previewImage in
print(previewImage)
}
signature.setViewArea(viewArea: view.bounds)
signature.capture()
signature.upload { uploadSuccess, error in
print(uploadSuccess, error)
}
}catch {
print(error)
}

DispatchQueue.main.async {
self.signatureView!.removeFromSuperview()
}

DispatchQueue.main.async {
self.view.addSubview(self.signatureView!)
}

}

@IBAction func captureAct(_ sender: UIButton) {
signature.capture()
}

@IBAction func clearAct(_ sender: UIButton) {
signature.clear()
}

}