> ## 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.

# 定向

> 你告诉 SDK 的关于剧集、观众和同意的信息，以及每个字段为什么能提高填充率和价格。

我们的广告是情境化的：服务器越了解屏幕上是什么、谁在看，匹配、填充和价格就越好。设备侧的信息由 SDK 自行收集。有三样东西来自你。

## 内容

`KontextVideo.Content` 描述 `VideoAds` 对应的剧集。两个字段必填；其余都是信号，每多一个字段都有帮助。

```swift theme={null}
let content = KontextVideo.Content(
    id: "100001-6",
    language: "en",
    title: "Episode 6",
    duration: 92,
    episodeNumber: 6,
    genre: "romance",
    keywords: ["forced love", "fantasy", "ceo"],
    categories: ["640", "653"],
    mediaRating: .safe,
    url: URL(string: "https://example.com/series/100001/episode/6"),
    series: .init(id: "100001", title: "My Marionette Lover", episodeCount: 40)
)
```

| 字段 | 为什么重要 |
| - | - |
| `id`、`language` | 必填。语言决定哪些广告活动有资格参与。 |
| `title`、`description`、`keywords`、`genre` | 情境匹配：爱情剧和罪案剧吸引不同的广告主。 |
| `categories` | IAB 内容分类 3.0 的 id，广告主定向所用的词汇表。 |
| `series` | 让广告活动跟随一部剧的各集；`episodeCount` 和 `episodeNumber` 说明观众看到了哪里。 |
| `duration` | 衡量机会的大小。 |
| `mediaRating` | `.safe` 或 `.explicit`。露骨内容不会得到要求安全内容的广告。不知道时留空；永远不要默认设置。 |
| `url` | 剧集的公开页面（如果有）。 |

时间单位为秒。

## 观众

一旦知道就设置到共享实例上；下一次请求会携带它。

```swift theme={null}
KontextVideo.shared.user = .init(
    id: "user-84213907",
    email: "viewer@example.com",        // 或 emailHash
    keywords: ["sci-fi", "cooking"]
)
```

* `id` 是你自己为观众设定的稳定标识，用于频次上限和个性化。
* `email` 或 `emailHash` 改进跨设备的匹配与去重。只有在观众同意允许时才发送明文地址；我们的服务器到达时即哈希，从不存储明文。或者你自己发送规范化地址的 SHA-256。
* `keywords` 是你用自己的话描述的观众兴趣。

## 同意

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

如果你的应用运行符合 TCF 的同意管理平台，SDK 每次请求都从标准共享存储读取其同意字符串，你无需设置。COPPA 无法从设备读取，所以始终由你提供。见 [TCF 与 CMP](https://docs.kontext.so/zh/video/guides/tcf-cmp.md) 和[合规](https://docs.kontext.so/zh/video/resources/compliance.md)。

## SDK 自行发送的信息

设备型号和操作系统、区域、屏幕尺寸和方向、网络类型、观众允许追踪时的广告标识符（见 [IFA 与 ATT](https://docs.kontext.so/zh/video/guides/ifa.md)）、你应用的 bundle id 和版本，以及你把播放器交给 SDK 时请求当下的内容播放位置。除了 ATT 设置，这些都不需要你写代码。

## A/B 测试

`KontextVideo.shared.variantId` 选择一个与 Kontext 约定的变体，例如比较两种素材风格。在你希望生效的请求之前设置。

## 下一步

> **[IFA 与 ATT](https://docs.kontext.so/zh/video/guides/ifa.md)**
>
> 广告标识符的一次性设置。

> **[API 参考](https://docs.kontext.so/zh/video/sdk/swift/api.md#kontextvideo-content)**
>
> `Content`、`User` 和 `Regulatory` 的每个字段。


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