# AI 辅助集成

使用 AI 编程助手在您的项目中集成和配置 Pushwoosh Flutter 插件。通过将您的助手连接到 [Context7](https://context7.com/) MCP 服务器，它可以访问最新的插件文档、代码示例和 API 参考——从而生成准确、可用的集成代码。

<Aside type="note">
您的 AI 助手必须支持 [MCP (模型上下文协议)](https://modelcontextprotocol.io/) 才能使用 Context7。支持的工具包括 **Claude Code**、**Cursor**、**Windsurf**、**Cline** 等。
</Aside>

## 工作原理

Context7 是一个 MCP 服务器，为 AI 助手提供最新的库文档。当您的助手可以访问 Context7 时，它可以在对话期间直接获取最新的 Pushwoosh Flutter 插件文档、代码片段和 API 参考——而不是依赖可能过时的训练数据。

Pushwoosh Flutter 插件在 Context7 上的库 ID：**`/pushwoosh/pushwoosh-flutter`**

## 设置 Context7

将 [Context7](https://github.com/upstash/context7#installation) 添加到您的 AI 助手的 MCP 配置中：

<Tabs>
  <TabItem label="Claude Code">
运行以下命令：

```bash
claude mcp add --scope user context7 -- npx -y @upstash/context7-mcp --api-key YOUR_API_KEY
```
  </TabItem>
  <TabItem label="Cursor / Windsurf">
添加到您的 MCP 配置文件（`.cursor/mcp.json` 或等效文件）：

```json
{
  "mcpServers": {
    "context7": {
      "command": "npx",
      "args": ["-y", "@upstash/context7-mcp@latest"]
    }
  }
}
```
  </TabItem>
</Tabs>

## 示例提示

配置好 Context7 后，您可以使用自然语言提示来集成插件。以下是用于常见任务的即用型提示。

### 基础插件集成

```text
Integrate Pushwoosh Flutter plugin into my Flutter project.

Requirements:
- Install pushwoosh_flutter via pub
- Initialize Pushwoosh with my App ID in main()
- Register for push notifications and handle onPushReceived and onPushAccepted streams

Use Context7 MCP to fetch Pushwoosh Flutter plugin documentation.
```

### 标签和用户分群

```text
Show me how to use Pushwoosh tags in a Flutter app for user segmentation.
I need to set tags, get tags, and set user ID for cross-device tracking.

Use Context7 MCP to fetch Pushwoosh Flutter plugin documentation for setTags and getTags.
```

### 消息收件箱集成

```text
Integrate Pushwoosh Message Inbox into my Flutter app. Show me how to:
- Display the inbox UI with custom styling using PWInboxStyle
- Load messages programmatically
- Track unread message count

Use Context7 MCP to fetch Pushwoosh Flutter plugin documentation for presentInboxUI.
```

<Aside type="tip">
在提示末尾添加 **“使用 Context7 MCP 获取 Pushwoosh Flutter 插件文档”** 会告知 AI 助手在生成代码前拉取最新的插件文档。
</Aside>

## AI 助手获取的内容

当您的助手向 Context7 查询 Pushwoosh Flutter 插件时，它会收到：

- **安装说明** — pubspec.yaml 设置和平台特定配置
- **API 参考** — 公共类、方法和流定义
- **代码示例** — 用于常见用例的 Dart 代码片段
- **插件文档** — 核心插件、Inbox 和 Geozones 的指南
- **配置详情** — 初始化参数、iOS 和 Android 设置步骤