본문 바로가기

Cordova Updater 시작하기

GitHub

이 가이드는 다음을 추가하는 과정을 안내합니다. @capgo/cordova-updater iOS 및 Android에서 Capgo live updates를 받을 수 있도록 Cordova 앱에 설정하는 방법입니다.

사전 요구사항

사전 요구 사항
  • Cordova CLI 12 이상
  • Cordova Android 13 이상 및/또는 Cordova iOS 7 이상
  • Capgo 계정으로 (capgo.app/register)
  1. npm에서 플러그인을 설치하고 Capgo 앱 ID를 전달하세요:

    터미널 창
    cordova plugin add @capgo/cordova-updater --variable APP_ID=YOUR_CAPGO_APP_ID
  2. 선택 사항: 설치 시 기본값 재정의 (Capacitor updater와 동일한 변수 사용):

    터미널 창
    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. 플러그인 변수 변경 후 Native Build 준비:

    터미널 창
    cordova prepare android ios
document.addEventListener('deviceready', async () => {
await cordova.plugins.Updater.notifyAppReady();
});
  • 이 플러그인과 cordova-plugin-ionic-webview를 함께 사용하지 마세요.
  • 호출 notifyAppReady() 번들이 로드되는 즉시 호출하세요. 무거운 UI 작업으로 인해 롤백 가능 시간이 지연되기 전이어야 합니다.
  • Cordova scheme 설정을 올바르게 유지하세요.

이후 deviceready, 해당 플러그인은 다음을 통해 사용할 수 있습니다: 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 });
}
});

npm 패키지에 TypeScript 타입이 포함되어 있습니다:

import type { UpdaterPlugin } from '@capgo/cordova-updater';
declare const cordova: { plugins: { Updater: UpdaterPlugin } };
  • WebView가 기본 scheme에서 제공되려면 Cordova Android 13 이상이 필요합니다. https://localhost/ scheme.
  • 플러그인이 다음을 등록합니다: CordovaPluginPathHandler 다운로드한 bundle 에셋을 서빙하기 위해.

첫 번째 bundle 업로드하기

“첫 번째 bundle 업로드하기” 섹션

웹 에셋을 빌드한 후, Capgo CLI를 사용하여 업로드하세요 (Capacitor와 동일한 워크플로우):

터미널 창
bun run build
npx @capgo/cli@latest bundle upload --channel=production
  • 다음 설정과 비교해 보세요: Capacitor updater 설정 — 대부분의 옵션은 plugin.xml 변수와 매핑됩니다.
  • 읽어보세요 Live update 호환성 Native Build 플러그인 변경 사항을 배포하기 전에.
  • 나중에 Capacitor로 마이그레이션하시나요? Capgo 앱 ID와 채널은 그대로 유지하면 됩니다. 클라이언트 플러그인 패키지만 변경됩니다.