Passer à la navigation

Prise en main de Cordova Updater

GitHub

Ce guide vous guide à travers l'ajout de @capgo/cordova-updater to a Cordova app so you can receive Capgo live updates on iOS and Android.

ce plugin. Ionic WebView contourne les gestionnaires de schéma de Cordova, donc les ensembles téléchargés ne s'ouvriront pas.

Prérequis
  • Cordova CLI 12+
  • Android Cordova 13+ et/ou iOS Cordova 7+
  • Un compte Capgo (capgo.app/register)
  1. Installez le plugin à partir de npm et passez votre ID d'application Capgo :

    Fenêtre de terminal
    cordova plugin add @capgo/cordova-updater --variable APP_ID=YOUR_CAPGO_APP_ID
  2. Facultatif : surcharger les valeurs par défaut lors de l'installation (mêmes variables que l'Capacitor updater) :

    Fenêtre de terminal
    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. Préparez les projets natifs après avoir modifié les variables du plugin :

    Onglet Terminal
    cordova prepare android ios

Après deviceready, le plugin est disponible sous la forme de 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 });
}
});

Les types TypeScript sont livrés avec le package npm :

import type { UpdaterPlugin } from '@capgo/cordova-updater';
declare const cordova: { plugins: { Updater: UpdaterPlugin } };
  • Exige Cordova Android 13+ afin que la vue Web soit servie par défaut https://localhost/ schéma.
  • Le plugin enregistre un CordovaPluginPathHandler pour servir les actifs de bundle téléchargés.

Build your web assets, then upload with the Capgo CLI (same workflow as Capacitor):

Fenêtre de terminal
bun run build
bunx @capgo/cli@latest bundle upload --channel=production