# Init IOS SDK

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

### Import IOS Gotadi SDK vào project <a href="#import-ios-gotadi-sdk-vao-project" id="import-ios-gotadi-sdk-vao-project"></a>

Thêm thư viện Swift Package Manager sử dụng SDK link ở trên để add library vào project.

<div><figure><img src="/files/yglEucypuYYsRGdWaE8m" alt=""><figcaption></figcaption></figure> <figure><img src="/files/Y5gHrllwrH2vFW4KXkvd" alt=""><figcaption></figcaption></figure> <figure><img src="/files/wwSf95JVKEcRKee81OFB" alt=""><figcaption></figcaption></figure></div>

```
Build Project lần đầu để có thể import thư viện GotadiSDK
```

### Example Code khởi tạo IOSGotadiSDK <a href="#example-code-khoi-tao-iosgotadisdk" id="example-code-khoi-tao-iosgotadisdk"></a>

* Import IOSGotadiSDK
* Khởi tạo `IOSGotadiSDK` ở viewDidLoad để tối ưu performance
* Init SDK and setup `environment` of partner with `params`:
  * `env` : Môi trường deploy `[uat | prod]`
  * `partnername`: Partner Name , example: `“vib”`
  * `language`: Ngôn ngữ hiển thị `[”vi” | “en”]`
  * `token`: `JWT Token` lấy được sau khi authorize từ API authentication của Gotadi
  * `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)
                }
        })
    }
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://developer.gotadi.com/vietnamese/doi-tac-b2b2c/phuong-thuc-sdk/initiate-sdk/init-ios-sdk.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
