跳过内容

频道

Channels are the core mechanism for managing app updates in Capgo. They allow you to control how and when your users receive updates, enabling features like A/B testing, staged rollouts, and platform-specific updates.

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

  • 捆绑(版本)控制: 指定用户接收的捆绑(版本)
  • 平台目标: 在 iOS、Android 和 Electron 平台中进行目标
  • 更新策略: 控制更新的分发方式
  • 设备限制: 管理可以访问更新的设备

渠道配置选项

渠道配置选项
  • 公共: 将该渠道设置为新设备的默认渠道
  • 禁用在本机应用程序版本新于更新包版本时的自动更新: 在设备的本机应用程序版本新于渠道中可用的更新包版本时,防止更新(例如,设备在本机应用程序版本 1.2.3,渠道中有包(版本) 1.2.2)
  • disableAutoUpdate: 控制更新行为(“major”,“minor”,“version_number”,“none”)
  • ios/android/electron: 为特定平台启用/禁用
  • allow_device_self_set: 允许设备选择其渠道
  • allow_emulator: 允许在模拟器设备上更新
  • allow_dev: 允许在开发构建上更新
  1. 测试频道: 内部验证时维护测试频道
  2. 阶段性发布: 逐步更新部署使用多个频道
  3. 平台分离: 根据需要为 iOS、Android 和 Electron 创建单独的频道
  4. 包(版本)管理: 使用语义版本号为更新路径提供清晰的路径

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"
}

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
}