需要更快的 应用程序更新 without app store delays? Capgo 让您即刻将安全的Over-the-Air (OTA)更新推送给用户。跳过应用商店的审核流程,轻松保持应用程序最新状态。
关键点:
- 什么是Capgo? 一个开源平台,用于在 Capacitor 应用中实时更新。
- 为什么需要OTA更新? 节省时间,改善用户体验,快速修复bug。
- 如何开始?
- 安装 Capgo 插件:
npm install @capgo/capacitor-updater - 使用一个 API 密钥来配置您的应用。
- 使用“生产”或“beta”等频道来进行针对性的发布。
- 安装 Capgo 插件:
- 高级功能: 端到端加密、错误处理和 CI/CD 集成。
Capgo 的文档(capgo.app/docs)提供了从安装到高级配置的详细步骤,帮助您实现无缝更新。
CapgoCapacitorJs Live 更新插件

使用Capgo文档
在与OTA更新相关的工作中,有效地浏览文档至关重要。Capgo的文档提供了详细的指南,帮助您将实时更新集成到Capacitor应用中。
找到文档的位置
您可以访问Capgo的文档在 capgo.app/docs [1]. 文档根据特定目的组织成各个部分:
| 部分 | 目的 | 关键话题 |
|---|---|---|
| 开始 | 初始设置 | 安装步骤 API key设置 |
| 配置 | 核心设置 | 插件配置、环境设置 |
| API 参考 | 技术细节 | 方法、参数、返回值 |
| 安全 | 保护措施 | 加密设置、签名验证 |
| 故障排除 | 问题解决 | 常见问题、诊断工具 |
重要术语和概念
以下是您将遇到的关键术语:
- 频道: 这些是用于控制版本分发的更新流。例如,您可以设置“生产环境”,“beta”和“测试环境”频道,以便为不同用户组提供服务 [4].
- 更新策略: 这些定义了如何分发和应用更新。选项包括自动下载、安装时间和用户提示 [1].
- 应用程序状态监听器: 这些组件跟踪应用程序是否处于前台或后台 [4].
- 捆绑包: 包含应用程序新版本的打包更新文件,包括资产、code 变更和配置更新 [4].
Code 示例和教程
The documentation provides sample code to simplify integration. Here’s a basic example using TypeScript/JavaScript:
import { CapacitorUpdater } from '@capgo/capacitor-updater'
// Initialize the updater
await CapacitorUpdater.notifyAppReady()
For more advanced use cases, the documentation includes real-world examples, such as: [2][3]Switching channels for A/B testing
- Custom update flows with user prompts
- Handling errors and implementing rollbacks
- Integrating updates with CI/CD pipelines
- Each tutorial also highlights performance considerations and security aspects, helping you make informed decisions. The documentation is frequently updated to include the latest features and best practices.
For implementation details, check out the setup guide next. [1].
Setting Up OTA Updates
Set up OTA updates in __CAPGO_KEEP_0__ to streamline your deployment process. Follow these steps and tips for a hassle-free configuration.
Set up OTA updates in Capgo to streamline your deployment process. Follow these steps and tips for a hassle-free configuration.
OTA更新设置步骤
首先在您的Capgo项目中安装Capacitor插件:
npm install @capgo/capacitor-updater
npx cap sync
接下来,更新您的 capacitor.config.json 文件,使用您的 Capgo API密钥:
{
"plugins": {
"CapacitorUpdater": {
"autoUpdate": true,
"apiKey": "YOUR_API_KEY_HERE"
}
}
}
然后,在您的应用程序的主文件中初始化更新器,以检测更新:
import { CapacitorUpdater } from '@capgo/capacitor-updater';
await CapacitorUpdater.notifyAppReady();
完成此项后,您可以设置通道来管理不同的更新流:
更新通道设置
组织您的 更新通道 以适应您的部署需求:
| 通道类型 | 目的 | 使用场景 |
|---|---|---|
| 生产环境 | 稳定版本 | 普通用户群 |
| 测试环境 | 预发布测试 | QA团队和beta测试者 |
| beta | 功能测试 | 早期采用者 |
要上传一个更新到一个特定的频道,使用 Capgo CLI:
npx @capgo/cli upload -c production
更新方法
Capgo 提供了两种主要方式来处理更新:
自动更新
通过在配置中设置 autoUpdate: true 来启用自动更新。这确保了更新在后台应用,无需开发者额外的努力。
手动更新 为了更好的控制,您可以手动管理更新。使用以下模式来检查并应用更新:
// Check for updates
const update = await CapacitorUpdater.download();
// Install when ready
if (update) {
await CapacitorUpdater.set(update);
}
对于关键更新,您可以在进行之前提示用户:
if (update.version > currentVersion) {
const userConsent = await showUpdatePrompt();
if (userConsent) {
await CapacitorUpdater.set(update);
}
}
您还可以针对特定用户组使用自定义ID和通道:
await CapacitorUpdater.setCustomId('beta-tester-123');
await CapacitorUpdater.setChannel('beta');
最后,请确保包括错误处理和回滚选项:
try {
await CapacitorUpdater.set(update);
} catch (error) {
await CapacitorUpdater.reset(); // Revert to the last working version
console.error('Update failed:', error);
}
通过这些步骤,您的OTA更新系统就准备好了。探索高级设置来进一步定制更新过程。
sbb-itb-f9944d2
高级设置
提高你的 Capgo OTA更新 安全性和灵活的更新配置
这些选项确保了安全和smooth的更新体验,同时满足了应用商店的指南。
Capgo provides strong security protocols to safeguard your update bundles and deliver them securely to users. The platform uses end-to-end encryption with public-key cryptography for all updates [1]__CAPGO_KEEP_0__ 提供强大的安全协议来保护你的更新包并安全地将它们传递给用户。该平台使用了端到端的加密和公钥密码学来处理所有更新
// Enable bundle verification
await CapacitorUpdater.setVerifyBundles(true);
// Configure encryption settings
await CapacitorUpdater.configure({
encryption: {
enabled: true,
failOnError: true
}
});
以下是如何启用关键安全功能的方法:
| 安全功能组件包括: | 安全功能 | 描述 |
|---|---|---|
| 实现方式 | 使用加密签名验证包的真实性 | 通过调用 setVerifyBundles() 方法自动启用 |
| 回滚保护 | 如果更新失败,则回滚到稳定版本 | 更新过程中内置 |
| 访问控制 | 基于角色的权限管理更新 | 通过控制台配置 |
更新行为设置
您可以使用事件监听器和配置选项自定义更新的分发和安装方式。通过这些设置调整更新的时间和用户交互:
// Listen for when an update is available
CapacitorUpdater.addListener('updateAvailable', async (info) => {
if (info.version > currentVersion) {
// Custom update logic based on app state
const isAppInactive = await checkAppState();
if (isAppInactive) {
await CapacitorUpdater.download();
}
}
});
// Monitor download completion
CapacitorUpdater.addListener('downloadComplete', (info) => {
console.log(`Update ${info.version} ready to install`);
// Implement custom installation timing if desired
});
对于分阶段发布,您可以直接通过控制台或使用 code: 配置更新的分发
// Set custom update conditions for a gradual rollout
await CapacitorUpdater.configure({
rollout: {
percentage: 25, // Start with 25% of users
timeInterval: 24 // Increase rollout percentage every 24 hours
}
});
用于处理特定版本相关行为:
// Handle version-specific update failures
CapacitorUpdater.addListener('updateFailed', async (info) => {
if (info.error.code === 'VERSION_MISMATCH') {
await CapacitorUpdater.reset(); // Revert to the last stable version
// Optionally, handle error notification here
}
});
这些设置确保更新可靠,同时允许您根据应用程序的需求来定制更新过程。始终在Capgo的测试环境中彻底测试更新,然后才将其推送到生产环境。 [2].
解决方案指南
Capgo的错误日志和内置工具有助于解决OTA更新的挑战,同时确保您的应用程序符合商店的要求。
常见问题和解决方案
以下是典型问题及其解决方案:
-
下载失败 症状:下载过程会冻结或无法完成。 解决方案:检查您的网络连接,确认更新URL有效,并添加重试机制来处理中断。
-
版本冲突 症状: Updates either fail to install or cause app instability. 解决方案: 使用明确的版本号避免冲突,并为安全性实施回滚选项。
-
安装错误 症状: 更新失败或触发自动回滚。 解决方案: 确保在更新成功后调用
notifyAppReady()以防止回滚。
对于大于 50MB 的更新,分割它们为更小的文件可以在 Android 设备上提高性能。 [5].
使用详细的错误日志来捕捉问题。例如,实现此监听器:
CapacitorUpdater.addListener('updateFailed', (error) => {
console.log(`Update failed: ${error.code}`);
logUpdateError({
errorCode: error.code,
deviceInfo: error.device,
timestamp: new Date().toISOString()
});
});
通过结合错误日志与预检查,您可以有效地处理这些问题,然后关注合规性。
App Store 规则
仅仅修复技术问题是不够的 - 你的更新还需要符合 App Store 的指南。
Apple App Store 要求:
- 用户透明度: 清晰地告知用户更新的内容并获得他们的同意。
- 核心功能: 确保你的应用程序的主要功能保持不变并经过审查。
- 安全措施: 使用安全的方法传输更新。
Android 实现:
await CapacitorUpdater.configure({
updateNotification: {
title: "Update Available",
message: "A new version is available. Please update to access the latest features.",
requireUserConsent: true
}
});
最佳实践:
- 版本控制: __CAPGO_KEEP_0__逐步发布更新以减少冲突。
- 更新通知: 提供清晰易用的更新提示。
- 安全: 验证捆绑包的完整性并使用加密保护数据。
概要
本节将主要概念汇总在一起。
Capgo的文档提供了清晰的指南,帮助开发者在Capacitor应用中集成OTA更新,同时遵守应用商店的规定。
使用Capgo的资源,开发者可以实现必备功能,如 端到端加密 和 CI/CD集成从初始设置到高级配置,覆盖了所有内容 [1].
关键实现领域
| 方面 | 关键焦点 | 哪里可以找到 |
|---|---|---|
| 安全性 | 加密和完整性检查 | 安全功能 部分 |
| 符合性 | 满足苹果和安卓要求 | App Store 规则 指南 |
| 更新管理 | 版本控制和回滚选项 | 更新方法 指南 |
| 错误处理 | 日志和故障排除步骤 | 问题解决指南 |
这些区域构成了Capgo的更新管理系统的骨架。
Capgo的CLI和分析工具简化了 应用程序整个生命周期中 更新管理 [1].
如果您需要进一步的支持,您可以浏览 API 文档, 示例项目和 社区论坛 [2].
Keep going from How to Use Capgo Documentation for OTA Updates
如何使用__CAPGO_KEEP_0__ 文档进行 OTA 更新 How to Use Capgo Documentation for OTA Updates 如何使用__CAPGO_KEEP_0__ 文档进行 OTA 更新 来规划安全性和合规性,请将其连接到 加密 了解加密的实施细节,请参阅加密, for the implementation detail in Compliance, Capgo 安全扫描器 for the product workflow in Capgo 安全扫描器, Capgo 安全 for the product workflow in Capgo 安全,和 Capgo 信任中心 for the product workflow in Capgo 信任中心。