更新API端点
复制一个包含安装步骤和此插件的完整Markdown指南的设置提示。
以下是 code 在 JavaScript 中的示例,用于向插件发送更新
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:__CAPGO_KEEP_0__session_key: 必须填写,仅用于加密包 - 这是ivSessionKey由 encrypt 命令返回version: 版本标识符,遵循 HTTPS 包下载地址url包创建
查看如何创建兼容包并生成校验和的
自动更新文档查看加密包的 加密包文档.
它解释了加密工作流程的全部内容。 __CAPGO_KEEP_0__ __CAPGO_KEEP_0__
继续从更新API Endpoint
标题:继续从更新API Endpoint如果您正在使用 更新API Endpoint 来规划CI/CD自动化,连接它与 使用@capgo/capacitor-updater 为native能力在使用@capgo/capacitor-updater Capgo CI/CD 为产品工作流程在Capgo CI/CD Capgo Native Builds 为产品工作流程在Capgo Native Builds Capgo Integrations 为产品工作流程在Capgo Integrations中, CI/CD集成 为CI/CD集成的实现细节。