IOS SDK Migration
warning
To upgrade to Core AmaniSDK v3, you need to use it with the AmaniUI package.
Amani SDK Initialization
- SDK V1
- Amani UI
import UIKit
import Amani
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Customer login information
let customerModel = CustomerRequestModel(name: "CUSTOMER_NAME", email: "CUSTOMER_EMAIL", phone: "CUSTOMER_PHONE_NUMBER", idCardNumber: "CUSTOMER_ID_CARD")
// Initialize SDK
let amaniSDK = AmaniSDK.sharedInstance
// Configure SDK
amaniSDK.setDelegate(delegate: self)
amaniSDK.set(server: "SERVER_URL", token: "TOKEN", customer: customer)
/*
if dont want to use location permissions please provide with useGeoLocation parameter
amaniSDK.set(server: "SERVER_URL", token: "TOKEN", customer: customer,useGeoLocation: false)
select showing language with language parameter
amaniSDK.set(server: "SERVER_URL", token: "TOKEN", customer: customer,language: "tr")
amaniSDK.set(server: "SERVER_URL", token: "TOKEN", customer: customer,useGeoLocation: false,language: "tr")
*/
// Start SDK
DispatchQueue.main.async {
amaniSDK.showSDK(overParent: self)
}
}
}
Amani Delegate
extension ViewController:AmaniSDKDelegate{
func onConnectionError(error: String?) {
//do whatever when connection error
}
func onNoInternetConnection() {
//do whatever when no internet connection
}
func onEvent(name: String, Parameters: [String]?, type: String) {
/*
//type // Type returns list of EventType
//name // Amani Event Name. If there is more than one document,
returns the type of that document group else returns the type of the document
(the document type returns to you according to Amani standards).
//parameter // Parameter returns Response, Error of upload.
If there is available it shows which step (like "0" front, "1" back)
(log: "XXX_SG_0", ["Continuebtn","0"], "buttonpressed" )
*/
print("log : \(name), \(Parameters), \(type)")
}
func onKYCSuccess(CustomerId: Int) {
//do whatever when customer approved
}
func onKYCFailed(CustomerId: Int, Rules: [[String : String]]?) {
// Returns uncompleted fields
}
func onTokenExpired() {
// returns when token expired. Token needs to be refreshed and restart instance
}
}
import UIKit
import Amani
class AmaniInitializaion: UIViewController {
var amani: AmaniUI?
override func viewDidLoad() {
super.viewDidLoad()
amani.setDelegate(delegate: self)
amani?.set(server: baseURL, token: token, language: lng)
amani?.showSDK(on: self, completion: { [weak self] customer, error in
debugPrint(customer, error)
})
}
}
Amani Delegate
//MARK: We are setting AmaniDelegate to ViewController
//MARK: You can handle here result of AmaniSDK responses.
extension AmaniInitializaion:AmaniDelegate{
func onError(type: String, error: [AmaniSDK.AmaniError]) {
print(type)
print(error)
}
func onProfileStatus(customerId: String, profile: AmaniSDK.wsProfileStatusModel) {
print(profile)
}
func onStepModel(customerId: String, rules: [AmaniSDK.KYCRuleModel]?) {
print(rules)
}
}
You can get more detailed information about the messages coming from AmaniUI Delegate functions from this link. Profile Status