Leitfaden
Tutorial zum Cordova-Updater
@capgo/cordova-updater verwendet
@capgo/cordova-updater Capgo live Updates für Cordova iOS- und Android-Apps mit derselben JavaScript API wie @capgo/capacitor-updater. Die Cordova-Plugin installieren, aufrufen notifyAppReady() auf jedem Start und mit @capgo/cli.
Installation
cordova plugin add @capgo/cordova-updater --variable APP_ID=com.example.app
cordova prepare android ios
Grundlegende Verwendung
document.addEventListener('deviceready', async () => {
const { Updater } = cordova.plugins;
await Updater.notifyAppReady();
const { bundle } = await Updater.current();
console.log('Active bundle', bundle);
const latest = await Updater.getLatest();
if (latest.url && !latest.error) {
const downloaded = await Updater.download({
url: latest.url,
version: latest.version,
checksum: latest.checksum,
});
await Updater.next({ id: downloaded.id });
}
});
Plattformanforderungen
- Cordova Android 13+ und Cordova iOS 7+
- Standard-Cordova-Webview-Schemes (
https://localhost/auf Android,app://localhost/auf iOS) - Vermeiden
cordova-plugin-ionic-webview— es verhindert das Austauschen von Paketen
Ein neues Paket bereitstellen
bun run build
bunx @capgo/cli@latest bundle upload --channel=production
Praktische Tipps
- Verwenden Sie denselben Capgo Anwendungs-ID und Kanäle, wenn Sie auch ein Capacitor oder Electron-Client bereitstellen.
- Behandeln Sie native Plugin- oder Cordova-Plattform-Updates wie jede andere native Änderung: Bereitstellen Sie ein neues Laden-Programm, bevor Sie auf neue native APIs in JavaScript-Paketen angewiesen sind.
- Vollständige Einrichtungsanleitungen finden Sie in den Cordova-Updater-Dokumenten.