내용으로 건너뛰기

Electron Updater API Reference

GitHub

이 페이지에서는 모든 사용 가능한 메소드, 이벤트 및 Electron Updater의 구성 옵션을 문서화합니다.

기본 메서드

기본 메서드 섹션

notifyAppReady()

notifyAppReady() 섹션

각 앱 런칭 시 호출해야 함 bundle 로드 성공을 확인하고 자동 롤백을 방지

await updater.notifyAppReady();

download(options)

다운로드(옵션)

URL에서 패키지를 다운로드합니다.

const bundle = await updater.download({
url: 'https://example.com/bundle.zip',
version: '1.0.1',
checksum: 'sha256-hash', // Optional but recommended
sessionKey: '...', // For encrypted bundles
});

매개 변수:

옵션타입필수설명
url문자열다운로드할 패키지의 URL
version문자열Yes버전 식별자
checksum문자열아니오SHA256 체크섬
sessionKey문자열아니오세션 키

반환: BundleInfo 객체 id, version, status

다음(options)

다음(options)

다음 앱 재시작 시 로드할 패키지를 큐에 추가합니다.

await updater.next({ id: 'bundle-id' });

매개 변수:

옵션타입필수설명
id문자열패키지 ID를 큐에 설정

즉시 번들을 전환하고 앱을 다시 로드합니다.

await updater.set({ id: 'bundle-id' });

매개 변수:

옵션타입필수설명
id문자열활성화할 번들 ID

현재 버블을 가진 앱을 수동으로 다시 로드합니다.

await updater.reload();

delete(options)

delete(options) 섹션

스토리지에서 버블을 삭제합니다.

await updater.delete({ id: 'bundle-id' });

매개 변수:

옵션타입필수설명
id문자열예스삭제할 번들 ID

reset(options)

reset(options) 섹션

빌트인 버전 또는 마지막 성공 번들을 복원합니다.

// Reset to builtin
await updater.reset({ toLastSuccessful: false });
// Reset to last successful bundle
await updater.reset({ toLastSuccessful: true });

매개 변수:

옵션타입필수설명
toLastSuccessfulbooleanNo설정값이 true일 경우, 내장 버전 대신 마지막 성공한 버전으로 초기화합니다.

배포 정보

배포 정보

현재()

현재()

현재 배포 및 네이티브 버전에 대한 정보를 가져옵니다.

const info = await updater.current();
// { bundle: { id, version, status }, native: '1.0.0' }

목록(옵션)

목록(옵션)

다운로드한 모든 배포 목록을 가져옵니다.

const bundles = await updater.list();
// [{ id, version, status, downloaded, checksum }, ...]

다음으로 업데이트할 패키지를 가져옵니다.

getNextBundle()

다음으로 업데이트할 패키지를 가져옵니다.

const next = await updater.getNextBundle();
// { id, version, status } or null

애플리케이션 롤백을 디버깅하는 데 유용한 마지막 업데이트 정보를 가져옵니다.

const failed = await updater.getFailedUpdate();
// { id, version, reason } or null

애플리케이션 바이너리와 함께 배포된 버전을 가져옵니다.

const version = await updater.getBuiltinVersion();
// '1.0.0'

업데이트 확인

업데이트 확인 섹션

getLatest(options)

getLatest(options) 섹션

최신 버전이 서버에서 제공되는지 확인합니다.

const latest = await updater.getLatest();
if (latest.url && !latest.error) {
// Update available
console.log('New version:', latest.version);
console.log('Download URL:', latest.url);
} else if (latest.error) {
console.error('Error checking updates:', latest.error);
}

반환:

속성타입설명
url문자열다운로드 URL (업데이트가 없으면 빈 문자열)
version__CAPGO_KEEP_0__사용 가능한 버전
checksum__CAPGO_KEEP_0__SHA256 체크섬
sessionKey__CAPGO_KEEP_0__암호화 세션 키
error__CAPGO_KEEP_0__체크 실패 시 오류 메시지
message__CAPGO_KEEP_0__서버 메시지

채널 관리

채널 관리

setChannel(옵션)

setChannel(옵션)

장치에 특정 채널 assignment.

await updater.setChannel({ channel: 'beta' });

unsetChannel(옵션)

unsetChannel(옵션)

채널 assignment을 제거하고 기본값 사용.

await updater.unsetChannel();

getChannel()

getChannel()

현재 채널 assignment을 가져오기.

const channel = await updater.getChannel();
// { channel: 'production', status: 'set' }

listChannels()

listChannels() 섹션

이 앱의 모든 채널을 목록화합니다.

const channels = await updater.listChannels();
// ['production', 'beta', 'staging']

다운로드된 업데이트가 적용되는 시기를 제어합니다.

setMultiDelay(options)

지연 조건 섹션

업데이트가 적용되기 전에 충족해야 하는 조건을 설정합니다.

// Wait for app to be backgrounded
await updater.setMultiDelay({
delayConditions: [{ kind: 'background' }]
});
// Wait until specific date
await updater.setMultiDelay({
delayConditions: [{ kind: 'date', value: '2024-12-25T00:00:00Z' }]
});
// Wait for app to be killed and restarted
await updater.setMultiDelay({
delayConditions: [{ kind: 'kill' }]
});
// Multiple conditions (all must be met)
await updater.setMultiDelay({
delayConditions: [
{ kind: 'background' },
{ kind: 'date', value: '2024-12-25T00:00:00Z' }
]
});

지연 조건 유형:

종류설명
background선택적 지속 시간 (ms)앱이 백그라운드에 있도록 기다립니다
kill-앱이 종료되고 다시 시작될 때까지 기다립니다
dateISO 날짜 문자열특정 날짜/시간까지 기다립니다
nativeVersion버전 문자열네이티브 앱 업데이트를 기다립니다

cancelDelay()를 취소합니다

cancelDelay() 섹션

즉시 업데이트 적용

await updater.cancelDelay();

장치 식별

장치 식별

getDeviceId()

getDeviceId()

장치 고유 식별자 가져오기

const deviceId = await updater.getDeviceId();
// 'uuid-xxxx-xxxx-xxxx'

setCustomId(options)

setCustomId(options)

장치에 사용자 정의 식별자 설정 (분석에 유용)

await updater.setCustomId({ customId: 'user-123' });

설정

설정

setUpdateUrl(options)

setUpdateUrl(options)

런타임에 업데이트서버 URL을 변경합니다.

await updater.setUpdateUrl({ url: 'https://my-server.com/updates' });

setStatsUrl(options)

setStatsUrl(options)

statistic 보고 URL을 변경하세요.

await updater.setStatsUrl({ url: 'https://my-server.com/stats' });

setChannelUrl(options)

setChannelUrl(options) 섹션

채널 관리 URL을 변경하세요.

await updater.setChannelUrl({ url: 'https://my-server.com/channel' });

setAppId(options)

setAppId(options) 섹션

실행 중에 App ID를 변경하세요.

await updater.setAppId({ appId: 'com.example.newapp' });

getAppId() 함수

getAppId() 함수

현재 앱 ID를 가져옵니다.

const appId = await updater.getAppId();

디버그

디버그

setDebugMenu(options) 함수

setDebugMenu(options) 함수

디버그 메뉴를 활성화하거나 비활성화합니다.

await updater.setDebugMenu({ enabled: true });

debug 메뉴가 활성화되어 있는지 확인합니다.

debug 메뉴가 활성화되어 있는지 확인합니다.

debug 메뉴가 활성화되어 있는지 확인합니다.

const enabled = await updater.isDebugMenuEnabled();

업데이트 이벤트를 감지합니다.

업데이트 이벤트를 감지합니다.

클립보드에 복사 addListener:

updater.addListener('eventName', (event) => {
// Handle event
});

업데이트 이벤트

이벤트
이벤트 데이터이벤트 데이터설명
download{ percent, status }다운로드 진행 업데이트
updateAvailable{ bundle }새로운 업데이트가 있습니다
noNeedUpdate{ message }업데이트가 이미 최신 상태입니다
downloadComplete{ bundle }다운로드가 성공적으로 완료되었습니다
downloadFailed{ bundle, error }다운로드 실패
breakingAvailable{ bundle }업데이트가 불일치 (네이티브 업데이트가 필요합니다)
updateFailed{ bundle, reason }업데이트 설치가 실패했습니다
appReloaded{}앱이 다시 로드되었습니다
appReady{}notifyAppReady() was called

예시: 전체 이벤트 처리

예시: 전체 이벤트 처리
// Progress tracking
updater.addListener('download', (event) => {
updateProgressBar(event.percent);
});
// Update available notification
updater.addListener('updateAvailable', (event) => {
showNotification(`Update ${event.bundle.version} available!`);
});
// Handle completion
updater.addListener('downloadComplete', async (event) => {
// Queue for next restart
await updater.next({ id: event.bundle.id });
showNotification('Update will apply on next restart');
});
// Handle failures
updater.addListener('updateFailed', (event) => {
console.error('Update failed:', event.reason);
reportError(event);
});

생성자 옵션

생성자 옵션 섹션

생성자 옵션의 전체 구성 ElectronUpdater:

const updater = new ElectronUpdater({
// Required
appId: 'com.example.app',
// Version override
version: '1.0.0', // Override builtin version detection
// Server URLs
updateUrl: 'https://plugin.capgo.app/updates',
channelUrl: 'https://plugin.capgo.app/channel_self',
statsUrl: 'https://plugin.capgo.app/stats',
// Behavior
autoUpdate: true, // Enable automatic update checks
appReadyTimeout: 10000, // Milliseconds before rollback (default: 10000)
autoDeleteFailed: true, // Auto-delete failed bundles
autoDeletePrevious: true, // Auto-delete old bundles
resetWhenUpdate: true, // Reset to builtin on native update
// Channels
defaultChannel: 'production',
// Direct Update Mode
directUpdate: false, // 'atInstall' | 'onLaunch' | 'always' | false
// Security
publicKey: '...', // RSA public key for E2E encryption
// Dynamic Configuration
allowModifyUrl: false, // Allow runtime URL changes
allowModifyAppId: false, // Allow runtime App ID changes
persistCustomId: false, // Persist custom ID across updates
persistModifyUrl: false, // Persist URL changes
// Debug
debugMenu: false, // Enable debug menu (Ctrl+Shift+D)
disableJSLogging: false, // Disable console logs
// Periodic Updates
periodCheckDelay: 0, // Seconds between auto-checks (0 = disabled, min 600)
});

API Electron Updater에서 계속하기 참조

API Electron Updater에서 계속하기 참조 섹션

__CAPGO_KEEP_0__을 사용하는 경우 API Electron Updater 참조 API Electron Updater와 연결하여 대시보드와 API 작업을 계획하세요. @capgo/electron-updater 사용 Using @capgo/electron-updater의 원시 기능을 위해 API 개요 API 구현 세부 정보를 위한 소개 __CAPGO_KEEP_0__ 구현 세부 정보를 위한 API 키 API 구현 세부 정보를 위한 API 키, 그리고 장치 __CAPGO_KEEP_0__ 구현 세부 정보를 위한 장치.