跳过内容

通道

Capgo 中的通道是管理应用程序更新的核心机制。它们允许您控制您的用户何时接收更新,启用 A/B 测试、分阶段发布和平台特定更新等功能。

通道代表应用程序更新的分发跟踪。每个通道都可以配置特定的规则和约束:

  • 捆绑包(版本)控制: 指定用户接收的捆绑包(版本)
  • 平台目标: 目标特定平台(iOS/Android/Electron)
  • 更新策略: 控制更新的传递方式
  • 设备限制: 管理可以访问更新的设备

频道配置选项

频道配置选项
  • 公共: 将该频道设置为新设备的默认频道
  • disableAutoUpdateUnderNative: 在设备的原生应用版本新于更新包(版本)可用的频道(例如,设备在原生应用版本 1.2.3,频道有更新包(版本) 1.2.2)时,防止更新
  • disableAutoUpdate: 控制更新行为(“主版本”,“次版本”,“版本号”,“无”)
  • ios/android/electron: 当前常用给一个类下系统
  • allow_device_self_set: 设置机器认给类下
  • allow_emulator: 当前类下为类下系统上一个类下
  • allow_dev: 当前类下为类下系统上一个类下

Best Practices

: 李学会系统
  1. Testing Channel: 类下系统为类下系统上一个类下
  2. Staged Rollout: 使用多个渠道进行渐进式更新部署
  3. : 平台分离: 为 iOS、Android 和 Electron 创建单独的渠道
  4. : 版本控制: 使用 : 语义版本 为清晰的更新路径

: 端点

端点

: POST

: POST

https://api.capgo.app/channel/

: 创建或更新渠道配置

请求体

请求体
type disable_update = "major" | "minor" | "version_number" | "none"
interface ChannelSet {
app_id: string
channel: string
version?: string // bundle (version) name
public?: boolean
disableAutoUpdateUnderNative?: boolean
disableAutoUpdate?: disable_update
ios?: boolean
android?: boolean
electron?: boolean
allow_device_self_set?: boolean
allow_emulator?: boolean
allow_dev?: boolean
}

示例请求

示例请求
终端窗口
curl -X POST \
-H "authorization: your-api-key" \
-H "Content-Type: application/json" \
-d '{
"app_id": "app_123",
"channel": "beta",
"version": "1.2.0",
"public": false,
"disableAutoUpdate": "minor",
"ios": true,
"android": true,
"electron": true,
"allow_emulator": true
}' \
https://api.capgo.app/channel/

成功响应

成功响应
{
"status": "ok"
}

GET

GET

https://api.capgo.app/channel/

获取频道信息。返回每页50个频道。

  • app_id: 必填项。您的应用程序ID
  • page: 可选项。分页的页码
  • channel: 可选项。要检索的特定频道名称
终端窗口
# Get all channels
curl -H "authorization: your-api-key" \
"https://api.capgo.app/channel/?app_id=app_123"
# Get specific channel
curl -H "authorization: your-api-key" \
"https://api.capgo.app/channel/?app_id=app_123&channel=beta"
# Get next page
curl -H "authorization: your-api-key" \
"https://api.capgo.app/channel/?app_id=app_123&page=1"
interface Channel {
id: number;
created_at: string;
name: string;
app_id: string;
version: { // bundle (version) assigned to the channel
id: number,
name: string
};
created_by: string;
updated_at: string;
public: boolean;
disableAutoUpdateUnderNative: boolean;
disableAutoUpdate: boolean;
allow_emulator: boolean;
allow_dev: boolean;
}

在下面的响应中, version 指的是分配给频道的包(版本).

{
"data": [
{
"id": 1,
"name": "production",
"app_id": "app_123",
"version": {
"id": 1,
"name": "1.0.0"
},
"created_at": "2024-01-01T00:00:00Z",
"updated_at": "2024-01-01T00:00:00Z",
"created_by": "user_123",
"public": true,
"disableAutoUpdateUnderNative": false,
"disableAutoUpdate": false,
"allow_emulator": false,
"allow_dev": false
}
]
}

https://api.capgo.app/channel/

删除频道。请注意,这将影响使用此频道的所有设备.

interface Channel {
channel: string
app_id: string
}

示例请求

示例请求
终端窗口
curl -X DELETE \
-H "authorization: your-api-key" \
-H "Content-Type: application/json" \
-d '{
"app_id": "app_123",
"channel": "beta"
}' \
https://api.capgo.app/channel/

成功响应

示例成功响应
{
"status": "ok"
}

错误处理

示例错误处理

常见错误场景和响应:

// Channel not found
{
"error": "Channel not found",
"status": "KO"
}
// Invalid bundle (version) format
{
"error": "Invalid version format. Use semantic versioning",
"status": "KO"
}
// Invalid update policy
{
"error": "Invalid disableAutoUpdate value",
"status": "KO"
}
// Permission denied
{
"error": "Insufficient permissions to manage channels",
"status": "KO"
}

常见用例

常见用例
  1. Beta测试
{
"app_id": "app_123",
"channel": "beta",
"version": "1.2.0-beta",
"public": false,
"allow_emulator": true,
"allow_dev": true
}
  1. 生产发布
{
"app_id": "app_123",
"channel": "production",
"version": "1.2.0",
"public": true,
"disableAutoUpdate": "minor"
}
  1. 平台特定更新
{
"app_id": "app_123",
"channel": "ios-hotfix",
"version": "1.2.1",
"ios": true,
"android": false
}

从Channels继续

从Channels继续

如果您正在使用 Channels 来规划通道路由和分阶段发布,连接它 频道 关于频道的实现细节 频道 关于频道的实现细节 Beta测试解决方案 关于Beta测试解决方案的产品工作流程 版本目标解决方案 关于版本目标解决方案的产品工作流程 Capgo 环境最佳实践:使用一个移动应用ID进行分阶段 关于Capgo 环境最佳实践:使用一个移动应用ID进行分阶段的实际背景