Zum Inhalt springen

Manuelle Aktualisierung

Konfiguration

Fügen Sie dies zu Ihrer capacitorconfigjson hinzu, um Auto-Update zu deaktivieren

// capacitorconfigjson
{
"appId": "*******",
"appName": "Name",
"plugins": {
"CapacitorUpdater": {
"autoUpdate": false,
}
}
}

Verwendung

Sie können dieses Beispiel verwenden oder die Logik in Ihrer App nachbilden

import { CapacitorUpdater } from '@capgo/capacitor-updater'
import { SplashScreen } from '@capacitor/splash-screen'
import { App } from '@capacitor/app'
let data = {version: ""}
CapacitorUpdaternotifyAppReady()
AppaddListener('appStateChange', async(state) => {
if (stateisActive) {
// Do the download during user active app time to prevent failed download
data = await CapacitorUpdaterdownload({
version: '004',
url: 'https://github.com/Cap-go/demo-app/releases/download/004/distzip',
})
}
if (!stateisActive && dataversion !== "") {
// Do the switch when user leave app
SplashScreenshow()
try {
await CapacitorUpdaterset(data)
} catch (err) {
consolelog(err)
SplashScreenhide() // in case the set fail, otherwise the new app will have to hide it
}
}
})