> For the complete documentation index, see [llms.txt](https://developer.gotadi.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developer.gotadi.com/english/b2b2c-partner/sdk-method/initiate-sdk/init-ios-sdk.md).

# 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="/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 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)
                }
        })
    }
}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://developer.gotadi.com/english/b2b2c-partner/sdk-method/initiate-sdk/init-ios-sdk.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
