跳过内容

更新类型

Capgo 支持多种类型的即时更新 (OTA)。本页面列出了并解释了所有它们,以便您可以选择适合您的应用程序的合适 combination。

控制 更新下载后应用

类型描述使用场景
autoUpdate: atBackground在后台下载,应用程序在后台或用户杀死应用程序时大多数应用程序;最小的干扰
autoUpdate: atInstall首次安装或应用商店更新时立即应用新用户获取最新版本;已有用户使用默认流程
autoUpdate: onLaunch安装、应用商店更新或应用杀死后立即应用保持新鲜度和会话稳定性的平衡
autoUpdate: always下载更新时立即应用(包括恢复时)关键修复、状态简单的应用
autoUpdate: onlyDownload自动下载并触发 updateAvailable但永远不应用或设置下一个捆绑包Apps that show their own update prompt or control exactly when to call set()

Configure in capacitor.config.ts:

plugins: {
CapacitorUpdater: {
autoUpdate: 'atBackground', // default; true is still accepted
// or: 'off' | 'atInstall' | 'onLaunch' | 'always' | 'onlyDownload'
}
}

延迟条件

延迟条件

必须满足的条件 一个更新被安装之前。使用 setMultiDelay 将它们组合起来(所有条件必须满足)。

条件描述示例
日期等待特定日期/时间后与服务器端发布协调
后台等待应用程序后台最小持续时间(毫秒)避免在快速应用程序切换期间应用
原生版本要求最低原生二进制版本阻止不兼容的本机code
杀死等待下一个应用程序杀死事件仅在完全重启时应用
import { CapacitorUpdater } from '@capgo/capacitor-updater';
await CapacitorUpdater.setMultiDelay({
delayConditions: [
{ kind: 'date', value: '2023-06-01T00:00:00.000Z' },
{ kind: 'background', value: '60000' },
],
});

版本阻止(通道政策)

版本阻止(通道政策)

控制哪些 semver更新 一个频道将自动分发。通过 --disable-auto-update 在频道中

策略允许用例
Nothing所有更新默认; 全自动更新
主要0.0.0 → 1.0.0同一主版本(例如1.x → 1.y)防止破坏性更改到达旧本机
次要0.0.0 → 1.1.0, 1.1.0 → 1.2.0同一次要版本(例如1.2.x → 1.2.y)更严格的控制在主版本
补丁除补丁升级外的任何更改仅0.0.311 → 0.0.314非常严格;仅补丁更新
元数据不带有 min_update_version带有明确的兼容性元数据的更新按捆绑定定制兼容性规则
__CAPGO_KEEP_0__
npx @capgo/cli channel set production --disable-auto-update major

How the bundle is transferred to the device.

TypeDescriptionWhen to Use
Full bundleEntire JS bundle is downloadedFirst install, large changes, or when delta is unavailable
Delta (manifest)Only changed files are downloaded最快的更新; 更加节省带宽
终端窗口
# Full bundle (default)
npx @capgo/cli bundle upload --channel production
# Delta updates
npx @capgo/cli bundle upload --channel production --delta

快速参考

快速参考部分
分类类型
应用时机off, atBackground, atInstall, onLaunch, always, onlyDownload
延迟条件date, background, nativeVersion, kill
版本阻塞none, major, minor, patch, metadata
交付全包, Delta (清单)

如果您正在使用 Update Types 来规划实时更新的交付,连接它与 Capgo Live Updates 为Capgo Live Updates中的产品工作流程 概述 __CAPGO_KEEP_0__ 功能 __CAPGO_KEEP_1__ 更新行为 __CAPGO_KEEP_2__ 开始使用 __CAPGO_KEEP_3__