본문 바로가기

Cordova Updater 시작하기

GitHub

이 가이드는 @capgo/cordova-updater 을 Cordova 앱에 추가하여 iOS와 Android에서 Capgo 라이브 업데이트를 받는 방법을 안내합니다.

  • Cordova CLI 12+
  • Cordova Android 13+ 및/또는 Cordova iOS 7+
  • Capgo 계정 (capgo.app/register)
  1. npm에서 플러그인을 설치하고 Capgo app 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. 플러그인 변수 변경 후 네이티브 프로젝트를 준비하세요:

    터미널 창
    cordova prepare android ios
document.addEventListener('deviceready', async () => {
await cordova.plugins.Updater.notifyAppReady();
});

자주 하는 실수

“흔한 실수” 섹션
  • 이 플러그인과 cordova-plugin-ionic-webview를 함께 사용하지 마세요.
  • 호출하세요 notifyAppReady() bundle이 로드되는 즉시—무거운 UI 작업이 롤백 윈도우를 지연시키기 전에.
  • Cordova 스키마 설정을 올바르게 유지하세요.

JavaScript 사용법

“JavaScript 사용” 섹션

로컬에서 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 });
}
});

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

import type { UpdaterPlugin } from '@capgo/cordova-updater';
declare const cordova: { plugins: { Updater: UpdaterPlugin } };

플랫폼 참고 사항

“Platform notes” 섹션
  • WebView가 기본적으로 제공되도록 Cordova Android 13+가 필요합니다 https://localhost/ 필요합니다.
  • 이 플러그인은 CordovaPluginPathHandler 다운로드한 bundle 에셋을 서빙하기 위해.

첫 번째 번들을 업로드하세요

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

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

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