更新API端点
复制一个包含安装步骤和此插件的完整Markdown指南的设置提示。
以下是 JavaScript 中 code 的示例,用于向插件发送更新
interface AppInfos { version_name: string version_build: string version_os: string custom_id?: string is_prod?: boolean is_emulator?: boolean plugin_version: string platform: string app_id: string device_id: string}
export const handler: Handler = async (event) => { const body = JSON.parse(event.body || '{}') as AppInfos const { platform, app_id, version_os, device_id, version_name, version_build, plugin_version, } = body console.log('update asked', platform, app_id, version_os, device_id, version_name, version_build, plugin_version) if (version_name === '1.0.0') { return { version: '1.0.1', url: 'https://apiurl.com/mybuild_101.zip', checksum: 'sha256_checksum_of_bundle', } } else if (version_name === '1.0.1') { return { version: '1.0.2', url: 'https://apiurl.com/mybuild_102.zip', checksum: 'sha256_checksum_of_bundle', } } else { return { message: 'Error version not found' version: '', url: '', } }}响应格式
标题为“响应格式”的部分用于 非加密包, 你的端点应该返回:
{ "version": "1.0.2", "url": "https://apiurl.com/mybuild_102.zip", "checksum": "sha256_checksum_of_bundle"}对于 加密包, 你也需要包括会话密钥:
{ "version": "1.0.2", "url": "https://apiurl.com/mybuild_102.zip", "checksum": "encrypted_checksum_from_encrypt_command", "session_key": "ivSessionKey_from_encrypt_command"}如果没有更新或错误,添加 message 密钥和可选的 error:
{ "message": "Version not found", "error": "The backend crashed", "version": "1.0.2",}标题为“字段描述”
:你的包 zip 文件 SHA256 散列值用于完整性验证checksum复制到剪贴板session_key: 必须填写,仅用于加密包 - 这是ivSessionKey由 `encrypt` 命令返回version: 版本标识符,遵循 格式url: 可以下载包的 HTTPS URL
包创建
标题:包创建要了解如何创建兼容包并生成校验和,请参阅 自动更新文档.
对于加密包,请参阅 加密包文档 它解释了加密工作流程的完整细节。
继续从更新API Endpoint
标题:继续从更新API Endpoint如果您正在使用 更新API Endpoint 来规划CI/CD自动化,连接它与 使用@capgo/capacitor-updater 对于在使用@capgo/capacitor-updater中的本机能力 Capgo CI/CD 对于Capgo CI/CD中的产品工作流 Capgo Native Builds 对于Capgo Native Builds中的产品工作流 Capgo Integrations 为产品工作流程中的Capgo集成,以及 CI/CD集成 为CI/CD集成的实现细节。