Zum Inhalt springen

Einführung in Cordova Updater

GitHub

Diese Anleitung führt Sie durch das Hinzufügen @capgo/cordova-updater zu einer Cordova-Anwendung, damit Sie Capgo live Updates auf iOS und Android erhalten.

  1. Installieren Sie das Plugin von npm und geben Sie Ihre Capgo-Anwendungs-ID ein:

    Terminalfenster
    cordova plugin add @capgo/cordova-updater --variable APP_ID=YOUR_CAPGO_APP_ID
  2. Optional: Überschreiben Sie die Standardsätze bei der Installation (gleiche Variablen wie der Capacitor-Updater):

    Terminalfenster
    cordova plugin add @capgo/cordova-updater \
    --variable APP_ID=YOUR_CAPGO_APP_ID \
    --variable DEFAULT_CHANNEL=production \
    --variable UPDATE_URL=https://plugin.capgo.app/updates \
    --variable AUTO_UPDATE=atBackground
  3. Vorbereiten Sie native Projekte nach Änderungen an Plugin-Variablen:

    Terminalfenster
    cordova prepare android ios

Nachdem deviceready, der Plugin ist als cordova.plugins.Updater:

document.addEventListener('deviceready', async () => {
const { Updater } = cordova.plugins;
await Updater.notifyAppReady();
const latest = await Updater.getLatest();
if (latest.url && !latest.error) {
const bundle = await Updater.download({
url: latest.url,
version: latest.version,
checksum: latest.checksum,
});
await Updater.next({ id: bundle.id });
}
});

Typs von TypeScript liefern mit dem Paket npm:

import type { UpdaterPlugin } from '@capgo/cordova-updater';
declare const cordova: { plugins: { Updater: UpdaterPlugin } };
  • Benötigt Cordova Android 13+ so das WebView wird von der Standard-Webseite geladen https://localhost/ Schematron.
  • Das Plugin registriert ein CordovaPluginPathHandler um heruntergeladene Bundle-Assets zu dienen.

Bauen Sie Ihre Web-Assets, dann laden Sie sie mit den Capgo CLI (gleiches Workflow wie Capacitor):

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