手动更新
复制一个包含安装步骤和本插件的完整 Markdown 指南的设置提示。
配置
配置将此添加到您的 capacitor.config.json,以禁用自动更新。
// capacitor.config.json{ "appId": "**.***.**", "appName": "Name", "plugins": { "CapacitorUpdater": { "autoUpdate": false, } }}使用
使用说明您可以使用此示例或在您的应用程序中重新创建逻辑。
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 } } })