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"
)
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)
}
}
You can't use any modules before completing these steps.
Profile Status
Key | Type | Description |
---|---|---|
amlStatus | boolean | Anti Money Laundering |
risk | Int | Range: 0-4. Shows the risk status of the profile |
status | String | Shows the general status of the profile, such as APPROVED, REJECTED, or PENDING |
customerId | String | Returns the UUID of the profile the user is connected to |
Steps Result
Key | Type | Description |
---|---|---|
result | ArrayList of Result | Returns the list of steps in the profile as an array list |
id | String | Returns the unique ID of the step |
status | String | Shows the related step status of the profile, such as APPROVED, REJECTED, or PENDING. |
sortOrder | Int | Ordering number of the related step for purpose of the ordering the related step into UI |
errors | List of Errors | Errors of the related steps happened during the process |
title | String | Returns Identification, Selfie, Address, Signature relate document titles you can handle which document trying to upload. (These are default values.) |
On Error
Key | Type | Description |
---|---|---|
type | String | Current error type as String |
error | ArrayList of AmaniError | Returns the list of the AmaniError |
Types
Error Types | Description |
---|---|
login_error | Current error type as String |
config_error | Errors related with fetching remote config |
selfie_error | Errors related with Selfie upload process |
id_error | Errors related with ID upload process |
signature_error | Errors related with Signature upload process |
customer_error | Errors related with Customer service fetch&po |
bio_login | Errors related with Bio login request. |
socket_error | General socket errors |
Errors
Error Code | Error Message |
---|---|
10500 | Server connection problem |
10501 | Connection Error |
10400 | No configuration found |
10404 | Image count didnt match with document |
10400 | No configuration found |
10100 | Profile id not found |
10101 | NFC response cannot be nil |
10604 | SSL certificate format error |
10502 | SSL Pinning Error |