设置
要对更新系统进行更精细的控制,您可以使用以下设置进行配置:
appReadyTimeout
Section titled “appReadyTimeout”配置原生插件在将更新视为”失败”之前应等待的毫秒数。
仅适用于 Android 和 iOS。
默认值: 10000 (10 秒)
{ "plugins": { "CapacitorUpdater": { "appReadyTimeout": 1000 } }}responseTimeout
Section titled “responseTimeout”配置原生插件在将 API 视为超时之前应等待的毫秒数。
仅适用于 Android 和 iOS。
默认值: 20 (20 秒)
{ "plugins": { "CapacitorUpdater": { "responseTimeout": 10 // (10 seconds) } }}autoDeleteFailed
Section titled “autoDeleteFailed”配置插件是否应自动删除失败的 bundle。
仅适用于 Android 和 iOS。
默认值: true
{ "plugins": { "CapacitorUpdater": { "autoDeleteFailed": false } }}autoDeletePrevious
Section titled “autoDeletePrevious”配置插件是否应在成功更新后自动删除之前的 bundle。
仅适用于 Android 和 iOS。
默认值: true
{ "plugins": { "CapacitorUpdater": { "autoDeletePrevious": false } }}autoUpdate
Section titled “autoUpdate”配置插件是否应通过更新服务器使用自动更新。
仅适用于 Android 和 iOS。
默认值: true
{ "plugins": { "CapacitorUpdater": { "autoUpdate": false } }}updateUrl
Section titled “updateUrl”配置发送更新检查的 URL / 端点。
仅适用于 Android 和 iOS。
默认值: https://plugin.capgo.app/updates
{ "plugins": { "CapacitorUpdater": { "updateUrl": "https://example.com/api/auto_update" } }}statsUrl
Section titled “statsUrl”配置发送更新统计信息的 URL / 端点。
仅适用于 Android 和 iOS。设置为 "" 以禁用统计报告。
默认值: https://plugin.capgo.app/stats
{ "plugins": { "CapacitorUpdater": { "statsUrl": "https://example.com/api/stats" } }}publicKey
Section titled “publicKey”配置端到端实时更新加密版本 2 的公钥。
仅适用于 Android 和 iOS。
默认值: undefined
{ "plugins": { "CapacitorUpdater": { "publicKey": "YOUR_PUBLIC_KEY" } }}directUpdate
Section titled “directUpdate”配置插件何时应直接安装更新。仅适用于 autoUpdate 模式。 适用于小于 10MB 的应用以及使用 —partial 标志完成的上传。 Zip 或超过 10MB 的应用对用户来说更新会相对较慢。
选项:
false: 永不执行直接更新(使用默认行为:启动时下载,后台时设置)'atInstall': 仅在应用安装、从商店更新时直接更新,否则表现为 directUpdate = false'onLaunch': 仅在应用安装、从商店更新或应用终止后直接更新,否则表现为 directUpdate = false'always': 在所有先前情况下直接更新(应用安装、从商店更新、应用终止或应用恢复后),永不表现为 directUpdate = falsetrue: (已弃用)与 “always” 相同,用于向后兼容
仅适用于 Android 和 iOS。
默认值: false
{ "plugins": { "CapacitorUpdater": { "autoUpdate": true, "directUpdate": "atInstall" } }}resetWhenUpdate
Section titled “resetWhenUpdate”当较新的原生应用 bundle 安装到设备时,自动删除之前下载的 bundle。
仅适用于 Android 和 iOS。
默认值: true
{ "plugins": { "CapacitorUpdater": { "resetWhenUpdate": false } }}defaultChannel
Section titled “defaultChannel”在配置中设置应用的默认频道。区分大小写。 此设置将覆盖云中设置的默认频道,但仍会遵守云中所做的覆盖。
仅适用于 Android 和 iOS。
默认值: undefined
{ "plugins": { "CapacitorUpdater": { "defaultChannel": "production" } }}在配置中配置应用的应用 ID。
仅适用于 Android 和 iOS。
默认值: undefined
{ "plugins": { "CapacitorUpdater": { "appId": "com.example.app" } }}version
Section titled “version”配置应用的当前版本。这将用于第一个更新请求。 如果未设置,插件将从原生代码获取版本。
仅适用于 Android 和 iOS。
默认值: undefined
{ "plugins": { "CapacitorUpdater": { "version": "1.0.0" } }}channelUrl
Section titled “channelUrl”配置频道操作的 URL / 端点。
仅适用于 Android 和 iOS。
默认值: https://plugin.capgo.app/channel_self
{ "plugins": { "CapacitorUpdater": { "channelUrl": "https://example.com/api/channel" } }}autoSplashscreen
Section titled “autoSplashscreen”使用 directUpdate 时自动处理启动屏隐藏。启用后,插件将在应用更新后或不需要更新时自动隐藏启动屏。 这消除了手动监听 appReady 事件并调用 SplashScreen.hide() 的需要。 仅在 directUpdate 设置为 “atInstall”、“always” 或 true 时有效。 需要安装 @capacitor/splash-screen 插件并配置 launchAutoHide: false。 需要启用 autoUpdate 和 directUpdate。
仅适用于 Android 和 iOS。
默认值: false
{ "plugins": { "CapacitorUpdater": { "autoUpdate": true, "directUpdate": "atInstall", "autoSplashscreen": true } }}periodCheckDelay
Section titled “periodCheckDelay”配置定期更新检查的延迟时间。单位为秒。 不能少于 600 秒 (10 分钟)。
仅适用于 Android 和 iOS。
默认值: 600 (10 分钟)
{ "plugins": { "CapacitorUpdater": { "periodCheckDelay": 600 // (10 minutes) } }}allowModifyUrl
Section titled “allowModifyUrl”允许插件从 JavaScript 端动态修改 updateUrl、statsUrl 和 channelUrl。
仅适用于 Android 和 iOS。
默认值: false
{ "plugins": { "CapacitorUpdater": { "allowModifyUrl": true } }}keepUrlPathAfterReload
Section titled “keepUrlPathAfterReload”配置插件在重新加载后保留 URL 路径。
仅适用于 Android 和 iOS。
默认值: false
{ "plugins": { "CapacitorUpdater": { "keepUrlPathAfterReload": true } }}disableJSLogging
Section titled “disableJSLogging”禁用插件的 JavaScript 日志记录。如果为 true,插件将不会记录到 JavaScript 控制台。只会执行原生日志。
仅适用于 Android 和 iOS。
默认值: false
{ "plugins": { "CapacitorUpdater": { "disableJSLogging": true } }}shakeMenu
Section titled “shakeMenu”启用摇动手势以显示更新菜单,用于调试/测试目的。
仅适用于 Android 和 iOS。
默认值: false
{ "plugins": { "CapacitorUpdater": { "shakeMenu": true } }}localHost
Section titled “localHost”配置 CLI 使用本地服务器进行测试或自托管更新服务器。
默认值: undefined
{ "plugins": { "CapacitorUpdater": { "localHost": "http://localhost:5173" } }}localWebHost
Section titled “localWebHost”配置 CLI 使用本地服务器进行测试或自托管更新服务器。
默认值: undefined
{ "plugins": { "CapacitorUpdater": { "localWebHost": "http://localhost:5173" } }}localSupa
Section titled “localSupa”配置 CLI 使用本地服务器进行测试或自托管更新服务器。
默认值: undefined
{ "plugins": { "CapacitorUpdater": { "localSupa": "http://localhost:54321" } }}localSupaAnon
Section titled “localSupaAnon”配置 CLI 使用本地服务器进行测试。
默认值: undefined
{ "plugins": { "CapacitorUpdater": { "localSupaAnon": "YOUR_LOCAL_ANON_KEY" } }}localApi
Section titled “localApi”配置 CLI 使用本地 API 进行测试。
默认值: undefined
{ "plugins": { "CapacitorUpdater": { "localApi": "http://localhost:54321/functions/v1" } }}localApiFiles
Section titled “localApiFiles”配置 CLI 使用本地文件 API 进行测试。
默认值: undefined
{ "plugins": { "CapacitorUpdater": { "localApiFiles": "http://localhost:54321/functions/v1/files" } }}