본문 바로가기

Electron Updater API 레퍼런스

GitHub

이 페이지는 Electron Updater에서 사용할 수 있는 모든 메서드, 이벤트 및 구성 옵션을 문서화합니다.

앱이 실행될 때마다 호출해야 합니다. bundle이 성공적으로 로드되었음을 확인하고 자동 롤백을 방지합니다.

await updater.notifyAppReady();

URL에서 bundle을 다운로드합니다.

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문자열지원Bundle를 다운로드할 URL
version문자열지원Bundle의 버전 식별자
checksum문자열아니요검증용 SHA256 체크섬
sessionKey문자열아니요암호화된 번들을 위한 세션 키

반환값: BundleInfo 다음 객체 id, version, status

다음 앱 재시작 시 로드될 번들을 큐에 추가합니다.

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

파라미터:

옵션유형필수설명
id문자열지원큐에 추가할 Bundle ID

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

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

파라미터:

옵션유형필수설명
id문자열지원활성화할 Bundle ID

현재 번들로 앱을 수동으로 다시 로드합니다.

await updater.reload();

스토리지에서 번들을 삭제합니다.

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

파라미터:

옵션유형필수설명
id문자열지원삭제할 Bundle ID

내장 버전 또는 마지막 성공한 bundle로 재설정합니다.

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

파라미터:

옵션유형필수설명
toLastSuccessfulboolean아니요true이면 builtin 대신 마지막으로 성공한 bundle로 재설정합니다.

현재 번들과 네이티브 버전 정보를 가져옵니다.

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

다운로드된 모든 번들을 나열합니다.

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

다음 재시작을 위해 대기 중인 번들을 가져옵니다.

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'

업데이트 확인

“Update Checking” 섹션

서버에서 최신 사용 가능 버전을 확인합니다.

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문자열사용 가능한 버전
checksum문자열SHA256 체크섬
sessionKey문자열암호화 세션 키
error문자열검증 실패 시 에러 메시지
message문자열서버 메시지

기기를 특정 채널에 할당합니다.

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

채널 할당을 제거하고 기본값을 사용합니다.

await updater.unsetChannel();

현재 채널 할당을 가져옵니다.

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

이 앱의 모든 사용 가능한 채널을 나열합니다.

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

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

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

// 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버전 문자열네이티브 앱 업데이트 대기

모든 지연 조건을 지우고 다음 확인 시 즉시 업데이트를 적용합니다.

await updater.cancelDelay();

고유한 기기 식별자를 가져옵니다.

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

기기에 대한 사용자 지정 식별자를 설정합니다(분석에 유용).

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

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

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

통계 보고 URL을 변경합니다.

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

채널 관리 URL을 변경합니다.

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

런타임에서 App ID를 변경합니다.

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

현재 App ID를 가져옵니다.

const appId = await updater.getAppId();

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

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

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

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() 호출됨

예제: 전체 이벤트 핸들링

“Example: Full Event Handling” 섹션
// 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)
});

Electron Updater API 레퍼런스에서 계속하기

Electron Updater에서 계속하기 API Reference

사용 중이라면 Electron Updater API 레퍼런스 대시보드 및 API 운영을 계획하려면, 이를 다음과 연결하세요 @capgo/electron-updater 사용하기 @capgo/electron-updater 사용하기에서 네이티브 기능을 위해, API 개요 구현 세부 사항은 API 개요에서 소개 구현 세부 사항은 소개에서 API 키 API Keys의 구현 세부 사항은, 기기 Devices의 구현 세부 사항은.