Skip to main content

Initializing the SDK

After installing the SDK, you must initialize it with a profile token from the server and other necessary information.

You can import the SDK to your file as shown below.

import Amani

SSL Pinning (Optional): Provides secure networking with SSL pinning activation. It's optional to use configuration, not mandatory. Must be called before the init method. Throws AmaniException in case of invalid certificate. Use in try catch block. Amani.setSSLPinning(certificate: URL) method.

  public func setSSLPinning(certificate:URL) throws{
do {
try sharedSDKInstance.setSSLPinning(certificate: certificate)
} catch (let error){
throw error
}
}

Creating a customer for the SDK. Only required field here is the idCardNumber field.

let customer = CustomerRequestMode(
name: "CUSTOMER_NAME", // Optional
email: "CUSTOMER_EMAIL", // Optional
phone: "CUSTOMER_PHONE_NUMBER", // Optional
idCardNumber: "CUSTOMER_ID_CARD"
)
note

idCardNumber field must match with the id_card_number field on the create customer endpoint.

After creating the CustomerRequestModel class, you can use the sharedInstance property to access the methods.

// on your UIViewController class
let amani = Amani.sharedInstance
override func viewDidLoad() {
super.viewDidLoad()
// initialize the AmaniSDK.
amani.setDelegate(self)
amani.initAmani(
server: "https://server.example",
token: token,
sharedSecret: "optional shared secret",
customer: customer,
apiVersion: .v2
) {[weak self] customerRes, error in
// TODO: Check for error
print(customerRes)
print(error)
}
}

And implement the delegate methods according to your usage.

extension ViewController: AmaniDelegate {

// Runs when the customer profile status changes
func onProfileStatus(customerId: String, profile: AmaniSDK.wsProfileStatusModel) {
print(profile)
}

// Runs when the customer completes a step, either successfuly or a failure
func onStepModel(customerId: String, rules: [AmaniSDK.KYCRuleModel]?) {
print(rules)
}

// Runs when the customer get errors kind of step or connection
func onError(type: String, error: [AmaniSDK.AmaniError]) {
print(type)
print(error)
}
}
warning

You can't use any modules before completing these steps.

Profile Status

KeyTypeDescription
amlStatusbooleanAnti Money Laundering
riskIntRange: 0-4. Shows the risk status of the profile
statusStringShows the general status of the profile, such as APPROVED, REJECTED, or PENDING
customerIdStringReturns the UUID of the profile the user is connected to

Steps Result

KeyTypeDescription
resultArrayList of ResultReturns the list of steps in the profile as an array list
idStringReturns the unique ID of the step
statusStringShows the related step status of the profile, such as APPROVED, REJECTED, or PENDING.
sortOrderIntOrdering number of the related step for purpose of the ordering the related step into UI
errorsList of ErrorsErrors of the related steps happened during the process
titleStringReturns Identification, Selfie, Address, Signature relate document titles you can handle which document trying to upload. (These are default values.)

On Error

KeyTypeDescription
typeStringCurrent error type as String
errorArrayList of AmaniErrorReturns the list of the AmaniError

Types

Error TypesDescription
login_errorCurrent error type as String
config_errorErrors related with fetching remote config
selfie_errorErrors related with Selfie upload process
id_errorErrors related with ID upload process
signature_errorErrors related with Signature upload process
customer_errorErrors related with Customer service fetch&po
bio_loginErrors related with Bio login request.
socket_errorGeneral socket errors

Errors

Error CodeError Message
10500Server connection problem
10501Connection Error
10400No configuration found
10404Image count didnt match with document
10400No configuration found
10100Profile id not found
10101NFC response cannot be nil
10604SSL certificate format error
10502SSL Pinning Error