# Init IOS SDK

{% hint style="info" %}
SDK link: <https://bitbucket.org/gotadigroup/gtd-ios-sdk>
{% endhint %}

### **Import Gotadi SDK into an iOS Project**

**Add the Library Using Swift Package Manager**

Use the SDK link above to add the library to your project via Swift Package Manager.

<div><figure><img src="https://3127657987-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fka3LMTlXv2Ay7BbFZMOc%2Fuploads%2FCF87oaOKskLPjbKF6Ybr%2FUntitled%201.png?alt=media&#x26;token=8b2f68ea-8b1f-4265-ad59-bcd12221b9bc" alt=""><figcaption></figcaption></figure> <figure><img src="https://3127657987-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fka3LMTlXv2Ay7BbFZMOc%2Fuploads%2Fx7WXRsz6wjKGjPesCBLd%2FUntitled%202.png?alt=media&#x26;token=6433b1b4-a083-4af2-a8e1-39e3b88312eb" alt=""><figcaption></figcaption></figure> <figure><img src="https://3127657987-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fka3LMTlXv2Ay7BbFZMOc%2Fuploads%2FPgt78bBP8lcxS3stqQvM%2FUntitled.png?alt=media&#x26;token=9f8d9d1c-19f9-4ebc-8ac3-39897e8db38d" alt=""><figcaption></figcaption></figure></div>

```
Build the project for the first time to import the GotadiSDK library.
```

### Example Code to Initialize IOSGotadiSDK

* **Import IOSGotadiSDK**
* Initialize **IOSGotadiSDK** in `viewDidLoad` for performance optimization.
* Init SDK and set up the partner environment with the following parameters:
  * `env`: Deployment environment \[`uat` | `prod`]
  * `partnername`: Partner name, e.g., `"vib"`
  * `language`: Display language \[`"vi"` | `"en"`]
  * `token`: JWT token obtained after authentication via Gotadi's API
  * `theme`: `primary`, `secondary`

```swift
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)
                }
        })
    }
}
```
