본문 바로가기

Electron Updater API 레퍼런스

GitHub

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

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

await updater.notifyAppReady();

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
});

파라미터:

옵션유형필수설명
urlstring지원bundle를 다운로드할 URL
versionstring지원bundle의 버전 식별자
checksumstring아니요검증을 위한 SHA256 체크섬
sessionKeystring아니요암호화된 번들의 세션 키

반환값: BundleInfo 다음 항목을 포함하는 object id, version, status

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

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

파라미터:

옵션유형필수설명
idstring지원큐에 추가할 Bundle ID

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

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

파라미터:

옵션유형필수설명
idstring지원활성화할 Bundle ID

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

await updater.reload();

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

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

파라미터:

옵션유형필수설명
idstring지원삭제할 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'

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

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);
}

반환값:

속성유형설명
urlstring다운로드 URL (업데이트가 없으면 빈 값)
versionstring사용 가능한 버전
checksumstringSHA256 체크섬
sessionKeystring암호화 세션 키
errorstring체크 실패 시 에러 메시지
messagestring서버 메시지

디바이스를 특정 채널에 할당합니다.

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' }
]
});

Delay Condition 유형:

종류값설명
background선택 사항 (ms)앱이 백그라운드로 전환될 때까지 대기
kill-앱 종료 및 재시작 대기
dateISO 날짜 문자열특정 날짜/시간까지 대기
nativeVersion버전 문자열Native Build 업데이트 대기

모든 지연 조건을 해제하고 다음 체크 시 즉시 업데이트를 적용합니다.

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의 구현 세부 사항은.