내용으로 건너뛰기

시작하기

GitHub

설치

설치

Capgo AI-Assisted Setup을 사용하여 플러그인을 설치할 수 있습니다. AI 도구에 Capgo 기능을 추가하려면 다음 명령어를 사용하세요:

터미널 창
npx skills add https://github.com/Cap-go/capgo-skills --skill capacitor-plugins

그다음에 다음 명령어를 사용하세요:

Use the `capacitor-plugins` skill from `Cap-go/capgo-skills` to install the `@capgo/capacitor-updater` plugin in my project.

만약 Manual Setup을 사용하는 경우, 플러그인을 설치하려면 다음 명령어를 실행하고 아래 플랫폼별 지침을 따르세요:

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

빠른 시작

빠른 시작

대부분의 사용자에게는 Quickstart 가이드를 따르는 것을 추천합니다. 기본 Quickstart 가이드 이 가이드는 플러그인 설치 및 Capgo 클라우드 통합에 대한 내용을 다룹니다.

이 가이드는 기술적인 플러그인 세부 사항에 초점을 맞추고, 내부 메커니즘을 이해하거나 자체 호스팅 업데이트를 구현하는 고급 사용자들을 위해 작성되었습니다.

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

  1. 업데이트 패키지 다운로드: 플러그인은 업데이트 패키지를 다운로드합니다 (ZIP 파일에 포함된 웹 자산)
  2. 추출: 장치의 저장소에 번들을 추출합니다.
  3. 자동 재로드: 앱이 새 번들을 사용하기 위해 재시작 없이 전환합니다.
  4. Fallback: 업데이트가 실패하면 앱은 이전에 작동하던 버전으로 돌아갑니다.

사용 모드

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

자동 업데이트를 위한 자동 관리를 사용하는 가장 쉬운 방법입니다.

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. 수동 모드

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

참조 main 자세한 내용은 여기서 확인할 수 있습니다.

Host your own update server:

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

Your server should return:

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

See Self-Hosted Mode for complete details.

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

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();
}
  • Always call notifyAppReady() 프로덕션으로 푸시하기 전에 업데이트 테스트를 철저히
  • 네트워크 오류에 대한 적절한 오류 처리를 구현
  • 버전 번호를 일관되게 사용
  • 다운로드 속도가 빠른 빠른 배포 크기를 유지
  • 업데이트 성공률을 모니터링
  • __CAPGO_KEEP_0__

다음 단계

다음 단계

지원

지원

Capgo를 사용 중이라면 Getting Started 자연 플러그인 작업을 계획하고자 한다면 Using @capgo/capacitor-updater Capgo native 기능을 사용하는 @capgo/capacitor-업데이터에 대해 Capgo 플러그인 디렉토리 Capgo 제품 워크플로우에 대한 플러그인 디렉토리에서 Capacitor Plugins by Capgo Capacitor 플러그인 구현 세부 사항을 위해 Capgo에 의해 구현됩니다. Capacitor 플러그인에서 플러그인을 추가하거나 업데이트 플러그인을 추가하거나 업데이트 하기 위해 이온 이코노미 플러그인 대체품의 제품 워크플로우에 대해.