# Concierge iOS SDK

* Version: **1.1.13**
* Minimum supported iOS version: **15** (this is what we test)
* Minimum compiling iOS version: **14** (this is where it compiles but not actually working and we block it by warning message on SDK initial screen)
* UI framework: SwiftUI
* Appearance: Light/Dark
* Supported orientations: Portrait
* Supported languages: English/Ukrainian/Russian/Kazakh

<figure><img src="https://3357793733-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F5t89kNfXUXFXgxM6GWtD%2Fuploads%2FzgpEVZs3lR5eVEP6xA2N%2Fdemo2.gif?alt=media&#x26;token=9454bfbf-9556-49ea-a053-4d4099d14ed3" alt=""><figcaption></figcaption></figure>

## How to setup the SDK

To get the dependency, you first need to configure access to our repository.

1. Install AWS CLI using this [guide](https://docs.aws.amazon.com/cli/latest/userguide/getting-started-version.html).
2. Configure AWS CLI using the credentials provided by us. To do this, run the following command in your terminal.

```shell
> aws configure

# After executing the command, you will be prompted to enter the following information
AWS Access Key ID [None]: <YOUR_ACCESS_KEY>
AWS Secret Access Key [None]: <YOUR_SECRET_KEY>
Default region name [None]: eu-central-1
Default output format [None]: json
```

3. Configure your swift client using this AWS CLI CodeArtifact command

```sh
aws codeartifact login --tool swift --repository concierge-sdk --domain infocus --domain-owner 346627266603 --region eu-central-1
```

4. Modify the Package.swift file within your application project directory to adjust the package dependencies utilized by your project. If the Package.swift file does not have a dependencies section, include one. Within the targets section, add the targets requiring the dependency.

```swift
...
    ],
    dependencies: [
        .package(id: "ios.concierge-ios-sdk", from: "1.1.10")
    ],
    targets: [
      .target(
         name: "MyApp",
         dependencies: ["concierge_sdk"]
      ),...
    ],
...
```

Use the **resolve** command to download the package dependencies from CodeArtifact.

```sh
swift package resolve
```

Alternatively, you can add packages by navigating to App > package dependencies on Xcode. “Click” on the + icon, Enter **ios.concierge-ios-sdk**. Once the package is found, choose the package and “Click” on **Add Package**. After a second or two, the package name appears on the list. On the top right side, you can verify the source repository (next to the **Registry** label).

<figure><img src="https://3357793733-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F5t89kNfXUXFXgxM6GWtD%2Fuploads%2F2wQOD9DDmovAHrwqY4Wg%2FScreenshot%202024-10-15%20at%2014.11.19.png?alt=media&#x26;token=6332afab-92ba-49a2-81b8-1dfe99abf04d" alt=""><figcaption></figcaption></figure>

5. Import the framework

```swift
import concierge_sdk
```

5. Add strings to Info.plist to avoid crashes&#x20;

<figure><img src="https://3357793733-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F5t89kNfXUXFXgxM6GWtD%2Fuploads%2FcqsMKdxiscjR9vs7TvGN%2FScreenshot%202025-03-16%20at%2022.39.04.png?alt=media&#x26;token=e7484140-734c-4832-8215-d086480dd9fa" alt=""><figcaption></figcaption></figure>

6. Since version 1.1.8 there are 2 convenience initialiser for SDK: by client token and by customer ID (like shown in code sample below). \
   \
   To init the SDK by client token you will need to set a client token and in which way the token was retrieved (by list of phone hashes or by customer id). **To obtain this token, your backend must have the appropriate API.** You need to implement the logic for retrieving this token from your backend and passing it to the SDK. Init ConciergeSDK with your client token

```swift
let conciergeSDK = ConciergeSDK(
    clientToken: "<<YOUR CLIENT TOKEN>>"
)
```

* If you don't have client ID at the moment then the only option left is to ask SDK to authenticate him/her via SMS/OTP. In order to do this you need to use another initialiser (like shown in code snippet below). You need to provide different type of token (retrieved from our backend) and use different initialiser. This token allows us to use different authentication mechanisms including SMS/OTP authentication.

<pre class="language-swift"><code class="lang-swift"><strong>let conciergeSDK = ConciergeSDK(
</strong>    withCustomerIdAccessToken customerIdAccessToken: String
)
</code></pre>

7. \[Optionally] Set language:

```swift
conciergeSDK.setLanguage(.en)
// You will need to execute conciergeSDK.createMainView() again
// to change texts in some system controls
```

8. \[Optionally] Set colors:

```swift
conciergeSDK.setColors(
    ConciergeColors(
        mainColor: Color(hex: "#C28BFC"),
        mainColorTinted: Color(hex: "#E3DEFC"),
        defaultShadowColor: Color.dynamicColor(
            light: Color(red: 0.525, green: 0.442, blue: 0.613, opacity: 0.13),
            dark: Color(red: 0.035, green: 0.031, blue: 0.157, opacity: 0.5)
        ),
        mainBlack: Color.dynamicColor(
            light: Color(hex: "#090828"),
            dark: Color(hex: "#E3DEFC")
        ),
        mainGray: Color.gray,
        mainWhite: Color(hex: "#FFFFFF"),
        background: Color.dynamicColor(
            light: Color(hex: "#F6F6FA"),
            dark: Color(hex: "#090828")
        ),
        intermediateBackgroundColor: Color.dynamicColor(
            light: Color(hex: "#FFFFFF"),
            dark: Color(hex: "#1E1240")
        ),
        searchIconColor: Color.gray,
        searchPlaceholderColor: Color.gray,
        hyperlinkColor: Color.blue
    )
)
```

9. \[Optionally] Set images:

```swift
conciergeSDK.setImages(
    ConciergeImages(
        conciergeAvatarImage: Image(systemName: "person"),
        infoLogoImage: Image(systemName: "apple.logo")
    )
)
```

10. \[Optionally] Set fonts:

```swift
conciergeSDK.setFonts(
    ConciergeFonts(customFontName: "Rubik-Medium")
)
```

11. \[Optionally] Set custom texts if needed:

```swift
conciergeSDK.setTexts( 
    ConciergeTexts(
        chatInfoAdditionalText: "For questions about Premium cards and transactions, please contact the XXXX toll-free line."
    )
)
```

12. \[Optionally] Set other UI settings if needed:

<pre class="language-swift"><code class="lang-swift"><strong>conciergeSDK.setUISettings(
</strong>    ConciergeUISettings(
        chatStyle: .messenger,
        chatFilePickerEnabled: true,
        shouldShowVisaLogoInInfo: false
    )
)
</code></pre>

13. Set delegate and implement delegate methods&#x20;

<pre class="language-swift"><code class="lang-swift"><strong>conciergeSDK.setDelegate(self)
</strong></code></pre>

14. Call start() function

```swift
conciergeSDK.start()
```

15. Instantiate SwiftUI view:

```swift
conciergeSDK.createMainView() 
```

Due to the tab bar and navigation bars, It should be presented as a full screen cover or as separate window\
\
Full example:

```swift
import SwiftUI
import concierge_sdk

class ContentViewModel: ObservableObject, ConciergeSDK.Delegate {
    enum State: Hashable {
        case loading
        case error(String)
        case regular
    }

    @Published var state: State = .loading
    
    let conciergeSDK: ConciergeSDK

    init() {
        let conciergeSDK = ConciergeSDK(
            clientToken: "<<YOUR CLIENT TOKEN>>",
            authType: .byPhoneHash /// or .byCustomerId
        )
        conciergeSDK.setLanguage(.kz)
        conciergeSDK.setColors(ConciergeColors(mainColor: .indigo))
        conciergeSDK.setImages(ConciergeImages(conciergeAvatarImage: Image(systemName: "person")))
        conciergeSDK.setFonts(ConciergeFonts(customFontName: "Rubik-Medium"))
        conciergeSDK.setTexts(ConciergeTexts(chatInfoAdditionalText: "<<Your additional text on chat info screen>>"))

        self.conciergeSDK = conciergeSDK
        
        conciergeSDK.setDelegate(self)
        conciergeSDK.start()
    }
    
    // MARK: ConciergeSDK.Delegate conformance
    
    func conciergeSDKDidStartSuccessfully(isSubscribed: Bool) {
        state = .regular
    }
    
    func conciergeSDKDidSubscribe() {
        // Update the SwiftUI view after subscription
        state = .regular
    }
    
    func conciergeSDKDidStartWithError(_ error: any Error) {
        state = .error(error.localizedDescription)
    }
    
    func conciergeSDKCantAuthorize() {
        conciergeSDK.setClientToken("<<NEW CLIENT TOKEN>>")
        conciergeSDK.start()
    }
}

struct ContentView: View {
    @ObservedObject var viewModel = ContentViewModel()

    var body: some View {
        switch viewModel.state {
        case .regular:
            viewModel.conciergeSDK.createMainView()
        case .loading:
            ProgressView()
        case .error(let string):
            VStack {
                Text(string)
            }
        }
    }
}
```
