跳转到正文

手动更新

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
}
}
})

如果你正在使用 手动更新 要规划迁移和企业运营,请将其与 使用 @capgo/capacitor-updater 用于“使用 @capgo/capacitor-updater”中的原生能力, Capgo 企业版 用于 Capgo Enterprise 中的产品工作流, Ionic Enterprise 插件替代方案 用于 Ionic Enterprise 插件替代方案的产品工作流, Capgo 替代方案 适用于 Capgo Alternatives 的产品工作流,以及 Capgo 咨询 适用于 Capgo Consulting 的产品工作流。