频道
复制一个包含安装步骤和本插件的完整 Markdown 指南的配置提示。
Capgo 中的通道是管理应用程序更新的核心机制。它们允许您控制您的用户何时接收更新,启用 A/B 测试、分阶段发布和平台特定更新等功能。
了解通道
标题:了解通道通道代表应用程序更新的分发轨迹。每个通道都可以配置特定的规则和约束:
- 捆绑包(版本)控制: 指定用户接收的捆绑包(版本)
- 平台目标: 目标特定平台(iOS/Android/Electron)
- 更新策略: 控制更新的传递
- 设备限制管理哪些设备可以访问更新
频道配置选项
频道配置选项- 公开设置为新设备的默认频道
- disableAutoUpdateUnderNative:防止当设备的原生应用程序版本 newer 比更新包(版本)可用的频道(例如,设备在原生应用程序版本 1.2.3,但频道有包(版本)1.2.2)
- disableAutoUpdate:控制更新行为(“major”,“minor”,“version_number”,“none”)
- ios/android/electron:为特定平台启用/禁用
- 允许设备自定义: 设备自行选择频道
- __CAPGO_KEEP_0__: 允许模拟器设备更新
- : 允许开发构建更新最佳实践
关于最佳实践的部分
测试频道- : 为内部验证保留测试频道: 使用多个频道进行渐进式更新部署
- : 分离不同平台: 分离不同平台
- : 分离不同平台: iOS、Android 和 Electron 时创建单独的频道
- Bundle (version) Control: 使用语义版本控制来清晰地定义更新路径
Endpoints
EndpointsPOST
POSThttps://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: 必填项。您的应用程序IDpage: Optional. 分页的页数channel: Optional. 指定要检索的特定频道名称
示例请求
标题:示例请求# Get all channelscurl -H "authorization: your-api-key" \ "https://api.capgo.app/channel/?app_id=app_123"
# Get specific channelcurl -H "authorization: your-api-key" \ "https://api.capgo.app/channel/?app_id=app_123&channel=beta"
# Get next pagecurl -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 } ]}DELETE
Section titled “DELETE”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"}常见用例
复制到剪贴板- 测试
{ "app_id": "app_123", "channel": "beta", "version": "1.2.0-beta", "public": false, "allow_emulator": true, "allow_dev": true}- 生产发布
{ "app_id": "app_123", "channel": "production", "version": "1.2.0", "public": true, "disableAutoUpdate": "minor"}- 平台特定更新
{ "app_id": "app_123", "channel": "ios-hotfix", "version": "1.2.1", "ios": true, "android": false}