Zum Hauptinhalt springen
Zurück zu Plugins
@capgo/cordova-updater
Tutorial
@capgo/cordova-updater

Cordova Updater

Live-Updates über das Internet für Cordova iOS und Android mit der gleichen API wie capacitor-updater

Führung

Anleitung zu Cordova Updater

Mit @capgo/cordova-updater

@capgo/cordova-updater bringt Capgo Live-Updates zu Cordova iOS- und Android-Anwendungen mit dem gleichen JavaScript API wie @capgo/capacitor-updater. Installieren Sie das Cordova-Plugin, rufen Sie notifyAppReady() auf jeden Start auf und laden Sie Pakete 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)
  • Vermeide cordova-plugin-ionic-webview — es verhindert das Bundle-Wechseln

Deploy ein neues Bundle

bun run build
bunx @capgo/cli@latest bundle upload --channel=production

Praktische Tipps

  • Wiederhole die gleiche Capgo App-ID und Kanäle, wenn du auch einen Capacitor oder Electron-Client auslieferst.
  • Behandle native Plugin- oder Cordova-Plattform-Updates wie jede andere native Änderung: Liefere ein neues Store-Binary, bevor du dich auf neue native APIs in JavaScript-Bundles verlässt.
  • Vollständige Einrichtungsanleitungen finden Sie in den Cordova-Updater-Dokumentation.