Import IOS Gotadi SDK vào project
Thêm thư viện Swift Package Manager sử dụng SDK link ở trên để add library vào project.
Build Project lần đầu để có thể import thư viện GotadiSDK
Example Code khởi tạo IOSGotadiSDK
import UIKit
import IOSGotadiSDK
class ViewController: UIViewController {
let gotadiSDK: IOSGotadiSDK = IOSGotadiSDK.shared
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
//TODO: Call API authorize get Token from Gotadi
gotadiSDK.setup(partnerSetting:
GotadiPartnerSetting(
env: "uat",
partnername: "vib",
language: "en", token: "token", theme: "primary"))
}
//TODO: Handle action push to gotadi search book
@IBAction func gotoGotadiSearchBook(_ sender: Any) {
gotadiSDK.pushToHomePartner(
partnerViewController: self,
handlePayment: {[weak self] gotadiViewController, bookingNumber in
//TODO: Handle payment after checkout and receive bookingInfo
print(bookingNumber)
if let paymentViewController =
self?.storyboard?.instantiateViewController(withIdentifier: "PaymentViewController")
as? PaymentViewController {
paymentViewController.bookingNumberResult = bookingNumber
gotadiViewController.navigationController?.pushViewController(paymentViewController, animated: true)
}
})
}
}