渠道
渠道是Capgo中管理应用更新的核心机制。它们允许您控制用户如何以及何时接收更新,启用A/B测试、分阶段推出和特定平台更新等功能。
渠道代表应用更新的分发轨道。每个渠道都可以配置特定的规则和约束:
- 版本控制: 指定用户接收的版本
- 平台定向: 针对特定平台(iOS/Android)
- 更新策略: 控制如何交付更新
- 设备限制: 管理哪些设备可以访问更新
渠道配置选项
Section titled “渠道配置选项”- public: 设置为新设备的默认渠道
- disableAutoUpdateUnderNative: 当设备的原生应用版本比渠道中可用的更新版本更新时阻止更新(例如,设备版本为1.2.3,但渠道有1.2.2)
- disableAutoUpdate: 控制更新行为(“major”, “minor”, “version_number”, “none”)
- ios/android: 为特定平台启用/禁用
- allow_device_self_set: 允许设备选择其渠道
- allow_emulator: 允许在模拟器设备上更新
- allow_dev: 允许在开发构建上更新
- 测试渠道: 维护用于内部验证的测试渠道
- 分阶段推出: 使用多个渠道进行渐进式更新部署
- 平台分离: 必要时为iOS和Android创建单独的渠道
- 版本控制: 使用语义版本控制以获得清晰的更新路径
https://api.capgo.app/channel/
创建或更新渠道配置。
Request Body
Section titled “Request Body”type disable_update = "major" | "minor" | "version_number" | "none"interface ChannelSet { app_id: string channel: string version?: string public?: boolean disableAutoUpdateUnderNative?: boolean disableAutoUpdate?: disable_update ios?: boolean android?: 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, "allow_emulator": true }' \ https://api.capgo.app/channel/{ "status": "ok"}https://api.capgo.app/channel/
检索渠道信息。每页返回50个渠道。
app_id: 必需。您的应用IDpage: 可选。分页的页码channel: 可选。要检索的特定渠道名称
# 获取所有渠道curl -H "authorization: your-api-key" \ "https://api.capgo.app/channel/?app_id=app_123"
# 获取特定渠道curl -H "authorization: your-api-key" \ "https://api.capgo.app/channel/?app_id=app_123&channel=beta"
# 获取下一页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: { id: number, name: string }; created_by: string; updated_at: string; public: boolean; disableAutoUpdateUnderNative: boolean; disableAutoUpdate: boolean; allow_emulator: boolean; allow_dev: boolean;}{ "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"}常见错误场景及其响应:
// 未找到渠道{ "error": "Channel not found", "status": "KO"}
// 无效的版本格式{ "error": "Invalid version format. Use semantic versioning", "status": "KO"}
// 无效的更新策略{ "error": "Invalid disableAutoUpdate value", "status": "KO"}
// 权限被拒绝{ "error": "Insufficient permissions to manage channels", "status": "KO"}- Beta测试
{ "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}