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
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)
}
}
warning
You can't use any modules before completing these steps.