Skip to content

Getting Started

GitHub

설치

설치
터미널 창
bun add @capgo/capacitor-updater
bunx cap sync

대부분의 사용자에게는 플러그인 설치 및 __CAPGO_KEEP_0__ 클라우드 통합을 포함하는 기본적인 빠른 시작 가이드를 따르기를 권장합니다. which covers both the plugin installation and Capgo cloud integration.

__CAPGO_KEEP_0__

Overview

Overview

Capacitor 업데이트 플러그인은 Capacitor 애플리케이션에 대한 오버-더-에어(OTA) 업데이트 기능을 제공합니다. 앱 스토어 리뷰를 거치지 않고 앱에 업데이트를 푸시할 수 있습니다.

How It Works

How It Works
  1. Bundle Download: 플러그인은 업데이트를 다운로드하는 업데이트 번들(ZIP 파일)을 다운로드합니다.
  2. Extraction: 번들은 장치의 저장소에 추출됩니다.
  3. Hot Reload: 앱은 새로운 번들을 사용하기 위해 재시작 없이 Switch합니다.
  4. Fallback: 업데이트 실패 시, 앱은 이전에 작동하던 버전으로 돌아갑니다.

사용 모드

사용 모드
자동 업데이트 모드 (권장)

자동 업데이트를 관리하는 데 자동으로 사용하는 가장 쉬운 방법:

import { CapacitorUpdater } from '@capgo/capacitor-updater';
// Plugin handles everything automatically
// Configure in capacitor.config.ts

설치 capacitor.config.ts:

{
plugins: {
CapacitorUpdater: {
autoUpdate: 'atBackground',
updateUrl: 'https://your-update-server.com/api/updates'
}
}
}

2. 수동 모드

수동 모드

업데이트 프로세스를 더 세밀하게 제어하기 위해:

import { CapacitorUpdater } from '@capgo/capacitor-updater';
// Download an update
const bundle = await CapacitorUpdater.download({
url: 'https://your-server.com/updates/v1.0.1.zip',
version: '1.0.1'
});
// Set the bundle (will be used on next app start)
await CapacitorUpdater.set({
id: bundle.id
});
// Or reload immediately
await CapacitorUpdater.reload();

플랫폼 설정

플랫폼 설정 섹션

추가 설정이 필요하지 않습니다. 플러그인은 BOX에서 작동합니다.

추가 설정이 필요하지 않습니다. 플러그인은 BOX에서 작동합니다.

기본 API 사용 방법

기본 API 사용 방법 섹션
import { CapacitorUpdater } from '@capgo/capacitor-updater';
const bundle = await CapacitorUpdater.download({
url: 'https://example.com/update.zip',
version: '1.0.1'
});
console.log('Downloaded bundle:', bundle.id);

활성 번들 설정

활성 번들 설정
// Set bundle to be used on next app start
await CapacitorUpdater.set({
id: bundle.id
});

새 번들과 다시 로드

새 번들과 다시 로드
// Reload app immediately with new bundle
await CapacitorUpdater.reload();

번들 목록

번들 목록
const { bundles } = await CapacitorUpdater.list();
console.log('Available bundles:', bundles);
await CapacitorUpdater.delete({
id: 'bundle-id'
});
const { bundle } = await CapacitorUpdater.current();
console.log('Current bundle:', bundle.version);

업데이트 이벤트를 듣기 위해:

import { CapacitorUpdater } from '@capgo/capacitor-updater';
// Listen for download progress
CapacitorUpdater.addListener('download', (info) => {
console.log('Download progress:', info.percent);
});
// Listen for download completion
CapacitorUpdater.addListener('downloadComplete', (bundle) => {
console.log('Download complete:', bundle.version);
});
// Listen for update failures
CapacitorUpdater.addListener('updateFailed', (error) => {
console.error('Update failed:', error);
});
// Listen for successful updates
CapacitorUpdater.addListener('updateAvailable', (info) => {
console.log('Update available:', info.version);
});

설정 플러그인을 자신의 capacitor.config.ts:

{
plugins: {
CapacitorUpdater: {
// Auto-update settings
autoUpdate: 'atBackground',
updateUrl: 'https://api.example.com/updates',
// Update behavior
resetWhenUpdate: true,
// Version settings
version: '1.0.0',
// Security
allowModifyUrl: false,
// Stats collection
statsUrl: 'https://api.example.com/stats',
// Channel (for Capgo cloud)
defaultChannel: 'production'
}
}
}

통합 패턴

통합 패턴

Capgo Cloud와 함께

Capgo Cloud와 함께

시작하기 가장 쉬운 방법:

// Install the Capgo CLI
bun add -g @capgo/cli
// Login to Capgo
npx @capgo/cli login
// Upload your first bundle
npx @capgo/cli bundle upload
// The plugin auto-updates from Capgo cloud

See the main Quickstart 가이드 자세한 내용은

자체 호스팅 업데이트

통합 패턴

자체 호스팅 업데이트 서버:

// Configure your update endpoint
{
plugins: {
CapacitorUpdater: {
autoUpdate: 'atBackground',
updateUrl: 'https://your-server.com/api/check-update'
}
}
}

서버는 다음과 같이 응답해야 합니다:

{
"version": "1.0.1",
"url": "https://your-server.com/updates/1.0.1.zip"
}

보기 자체 호스팅 모드 자세한 내용은

수동 업데이트 흐름

수동 업데이트 흐름

업데이트에 대한 완전한 제어:

import { CapacitorUpdater } from '@capgo/capacitor-updater';
async function checkAndUpdate() {
// Check for updates from your server
const response = await fetch('https://api.example.com/check-update');
const { version, url } = await response.json();
// Download the update
const bundle = await CapacitorUpdater.download({
url,
version
});
// Notify bundle is ready
await CapacitorUpdater.notifyAppReady();
// Set as next version
await CapacitorUpdater.set({ id: bundle.id });
// Reload when ready
await CapacitorUpdater.reload();
}

최선의 방법

Best Practices
  • 항상 앱이 성공적으로 로드 될 때 notifyAppReady() 테스트 업데이트를 충분히 하기 전에 프로덕션으로 푸시하지 마세요.
  • 네트워크 실패 시 적절한 오류 처리를 구현하세요.
  • 버전 번호를 일관되게 사용하세요.
  • 다운로드 속도가 빠른 작은 배포 크기를 유지하세요.
  • 업데이트 성공률을 모니터링하세요.
  • 다음 단계

Getting Started에서 계속

Getting Started에서 계속하는 섹션

native 플러그인 작업을 계획하고 있으면 Getting Started native 플러그인 작업을 계획하고 있으면 capgo-updater @capacitor capgo native 기능을 위한 @capacitor/__CAPGO_KEEP_2__-업데이터터를 사용하세요. Capgo 플러그인 디렉토리 Capgo 플러그인 디렉토리 내의 제품 워크플로우를 위한 Capgo에 의해 Capacitor 플러그인 Capacitor 플러그인에 대한 구현 세부 정보는 Capgo에 의해 Capacitor 플러그인에 의해 플러그인을 추가하거나 업데이트하는 __CAPGO_KEEP_0__ 플러그인에 대한 구현 세부 정보는 플러그인을 추가하거나 업데이트하는 아이오닉 엔터프라이즈 플러그인 대안 아이오닉 엔터프라이즈 플러그인 대안의 제품 워크플로우를 위한