> ## Documentation Index
> Fetch the complete documentation index at: https://docs.kontext.so/llms.txt
> Use this file to discover all available pages before exploring further.

# Installation

> Add the Video SDK to your iOS project, initialize it at launch, and configure ATT and SKAdNetwork.

> [!NOTE]
>
> You'll need a [publisher account](https://docs.kontext.so/publishers.md#getting-started-is-easy) to obtain your `publisherToken`.

## 1. Add the SDK

Add the package as a dependency in Xcode (File → Add Package Dependencies) or in `Package.swift`:

```swift theme={null}
dependencies: [
    .package(url: "https://github.com/kontextso/sdk-swift-video", .upToNextMajor(from: "0.1.0"))
]
```

Then add the `KontextVideoSDK` product to your app target.

> [!NOTE]
>
> The SDK depends on [KontextKit](https://github.com/kontextso/kontextkit-ios), shared iOS primitives (install id, device info, ATT, consent). Swift Package Manager pulls it in for you.

## 2. Initialize at launch

Call `initialize(with:)` once, as early as your app starts. It stores the configuration and calls the server in the background; nothing waits on it.

```swift theme={null}
import KontextVideoSDK

KontextVideo.shared.initialize(with: .init(publisherToken: "<your-publisher-token>"))
```

In `async` code the same call returns the resulting state:

```swift theme={null}
let state = await KontextVideo.shared.initialize(with: .init(publisherToken: "<your-publisher-token>"))
```

A second call is ignored. Every ads request made before initialization finishes simply waits for it, so you can create a `VideoAds` right away.

> [!NOTE]
>
> `KontextVideo`, `VideoAds` and `VideoAd` are `@MainActor`. Call them from the main actor, which is the default in SwiftUI views and in `@MainActor`-isolated view controllers.

### Configuration

```swift theme={null}
KontextVideo.Configuration(
    publisherToken: "<your-publisher-token>",
    requestTrackingAuthorization: true,    // the SDK asks for ATT before its first ads request; default false
    logLevel: .warning                      // .none, .error, .warning, .info, .debug
)
```

Use `logLevel: .debug` while integrating; it logs every request, every ad and every beacon to the console under the subsystem `so.kontext.video`.

## 3. Set up IDFA (App Tracking Transparency)

Add `NSUserTrackingUsageDescription` to `Info.plist`:

```xml theme={null}
<key>NSUserTrackingUsageDescription</key>
<string>We use your advertising identifier to show you more relevant ads.</string>
```

The Video SDK does not show the ATT dialog by default: a video app usually has its own moment for it. Request it yourself, or set `requestTrackingAuthorization: true` and the SDK asks right before its first ads request. Either way the SDK reads the IDFA once the viewer allowed it.

See [IFA & ATT](https://docs.kontext.so/video/guides/ifa.md) for the `Info.plist` key, prompt-timing gotchas, and how to manage the prompt yourself.

## 4. Set up SKAdNetwork

Add Kontext's ad network identifier, plus the DSP identifiers we provide during onboarding, to `Info.plist`:

```xml theme={null}
<key>SKAdNetworkItems</key>
<array>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>mp7rpxwdrx.adattributionkit</string>
  </dict>
</array>
```

Without Kontext's identifier, installs from directly-served campaigns silently won't be attributed. See [SKAdNetwork](https://docs.kontext.so/video/guides/skadnetwork.md) for the full guide.

## 5. Consent

If your app runs a TCF-compliant consent platform, the SDK reads the IAB consent keys it writes to `UserDefaults` on every request; nothing to do. COPPA cannot be read from the device, so set it yourself:

```swift theme={null}
KontextVideo.shared.regulatory = .init(coppa: false)
```

See [TCF & CMP](https://docs.kontext.so/video/guides/tcf-cmp.md).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.