Skip to main content

Signature

This module creates a canvas, and lets the users upload their signatures.

You can access the Signature module from the sharedInstance property as shown below.

caution

Before using this module please make sure you've initialized the SDK correctly.

let amaniSignature = Amani.sharedInstance.Signature()

Preparetion for starting the signature module

Before calling the start method of this module you have to create a view to be used as canvas, and create a to setup as confirm and and clear.

// setting the canvas frame
// for example purposes we used the whole frame of the view controller
// TODO: change this for a different view like a subview that needs to be drawable
amaniSignature.setViewArea(viewArea: view.bounds)

// setting the buttons
@IBAction func clearAct(_ sender: UIButton) {
amaniSignature.clear()
}

@IBAction func confirmAct(_ sender: UIButton) {
amaniSignature.confirm()
}

// setting the callbacks
amaniSignature.setOnConfirmPressedCallback {(image, currentSignatureNo) in
// TODO: do something with image
// TODO: do something with currentSignatureNo
}

Starting the module

Just call the start method, if you want to capture multiple set the stepId to the n-1 of the acutal count you want.

self.signatureView = amaniSignature.start(stepId: 2) {(previewImage) in
// preview image is the lastly taken signature
// TODO: show a preview screen uses previewImage

// remove the view
DispatchQueue.main.async {
self.signatureView.removeFromSuperview()
}
}

// add the view
DispatchQueue.main.async {
self.view.addSubview(signatureView)
}

Upload

After completing the capture process you can call the upload as shown below.

amaniScanNFC.upload(location: nil) {[weak self] isSuccess in
if (isSuccess != nil) {
// isSuccess is a boolean variable
// TODO: handle the upload state
}
}