跳过内容

手动更新

GitHub

添加到您的 capacitor.config.json,以禁用自动更新。

// capacitor.config.json
{
"appId": "**.***.**",
"appName": "Name",
"plugins": {
"CapacitorUpdater": {
"autoUpdate": "off",
}
}
}

您可以使用此示例或在您的应用中重建逻辑。

import { CapacitorUpdater } from '@capgo/capacitor-updater'
import { SplashScreen } from '@capacitor/splash-screen'
import { App } from '@capacitor/app'
let data = {version: ""}
CapacitorUpdater.notifyAppReady()
App.addListener('appStateChange', async(state) => {
if (state.isActive) {
// Do the download during user active app time to prevent failed download
data = await CapacitorUpdater.download({
version: '0.0.4',
url: 'https://github.com/Cap-go/demo-app/releases/download/0.0.4/dist.zip',
})
}
if (!state.isActive && data.version !== "") {
// Do the switch when user leave app
SplashScreen.show()
try {
await CapacitorUpdater.set(data)
} catch (err) {
console.log(err)
SplashScreen.hide() // in case the set fail, otherwise the new app will have to hide it
}
}
})

。它将处理所有这些问题。

Section titled “继续使用手动更新”

如果您正在使用 手动更新 来规划迁移和企业运营,连接它与 使用@capgo/capacitor-updater 为native能力在使用@capgo/capacitor-updater Capgo企业 为企业产品工作流程中的 Capgo 为产品工作流程在__CAPGO_KEEP_0__企业 Ionic企业插件替代品 Capgo 替代方案 Capgo替代品 Capgo 咨询 为产品工作流程在 Capgo 咨询中。