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

Cordova Updater

OTA-Lebend-Updates für Cordova iOS und Android mit demselben API wie capacitor-updater

Richtlinie

Tutorial zum Cordova-Updater

Mit @capgo/cordova-updater werden capgo-Live-Updates für Cordova-iOS- und -Android-Anwendungen mit derselben JavaScript-__CAPGO_KEEP_1__ wie

@capgo/cordova-updater brings Capgo live updates to Cordova iOS and Android apps with the same JavaScript API as @capgo/capacitor-updaterauf jedem Start auf und laden Sie Pakete mit notifyAppReady() Installation @capgo/cli.

Grundlegende Verwendung

cordova plugin add @capgo/cordova-updater --variable APP_ID=com.example.app
cordova prepare android ios

Installation

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

Ein neues Bundle bereitstellen

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

Praktische Tipps

  • Verwende das gleiche Capgo App-Id und Kanäle, wenn Sie auch ein Capacitor oder Electron-Client bereitstellen.
  • Behandle native Plugin- oder Cordova-Plattform-Updates wie jede andere native Änderung: Bereitstellen Sie ein neues Store-Binary, bevor Sie auf neue native APIs in JavaScript-Bundles angewiesen sind.
  • Detailliertere Einrichtungsanleitungen finden Sie in der Cordova-Updater-Dokumentation.