메뉴로 이동

Electron Updater API 참조

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

기본 메서드

기본 메서드

클립보드에 복사 주의: 사용에 주의가 필요합니다.

await updater.notifyAppReady();

__CAPGO_KEEP_0__(options)

제목 "__CAPGO_KEEP_0__(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__CAPGO_KEEP_0____CAPGO_KEEP_1____CAPGO_KEEP_2__
version__CAPGO_KEEP_0____CAPGO_KEEP_1____CAPGO_KEEP_3__
checksum__CAPGO_KEEP_4____CAPGO_KEEP_5____CAPGO_KEEP_6__
sessionKey__CAPGO_KEEP_7____CAPGO_KEEP_8____CAPGO_KEEP_9__

반환: BundleInfo 객체에 id, version, status

앱이 다시 시작될 때 다음으로 로드될 배포를 큐에 추가합니다.

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

매개 변수:

옵션타입필수설명
id문자열Bundle ID를 큐에 추가

__CAPGO_KEEP_0__

set(options) 섹션

즉시 앱을 재로드하고 Bundle로 Switch합니다.

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

매개 변수:

옵션타입필수설명
id문자열YesBundle ID to activate

Manually reload the app with the current bundle.

await updater.reload();

Copy to clipboard

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

Parameters:

Option타입필수설명
idstringYes삭제할 번들 ID

기본 버전 또는 마지막 성공 번들을 복원합니다.

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

매개 변수:

옵션타입필수설명
toLastSuccessfulboolean아니요true가면 마지막 성공한 번들로 리셋합니다.

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

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

__CAPGO_KEEP_0__

__CAPGO_KEEP_1__

__CAPGO_KEEP_2__

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

__CAPGO_KEEP_4__

__CAPGO_KEEP_5__

__CAPGO_KEEP_6__

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

__CAPGO_KEEP_8__

__CAPGO_KEEP_9__

__CAPGO_KEEP_10__

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

getBuiltinVersion()

getBuiltinVersion() 섹션

앱 바이너리와 함께 제공되는 버전을 가져옵니다.

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문자열사용 가능한 버전
checksumSHA256 체크섬암호화 세션 키
sessionKey체크 실패 시 오류 메시지__CAPGO_KEEP_0__
error__CAPGO_KEEP_1____CAPGO_KEEP_2__
messagestring서버 메시지

채널 관리

채널 관리

채널을 특정 채널에 할당합니다.

복사

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

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

__CAPGO_KEEP_0__

__CAPGO_KEEP_0__

__CAPGO_KEEP_0__

await updater.unsetChannel();

현재 채널 assignments을 가져옵니다.

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

listChannels()

listChannels() 섹션

이 앱에 사용 가능한 모든 채널을 목록화합니다.

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

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

setMultiDelay(options)

멀티 딜레이 옵션을 설정합니다.

Copy to clipboard

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

즉시 업데이트 적용을 위해 다음 체크 시 모든 지연 조건을 취소합니다.

await updater.cancelDelay();

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

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

__CAPGO_KEEP_0__

__CAPGO_KEEP_1__

__CAPGO_KEEP_2__

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

__CAPGO_KEEP_4__

__CAPGO_KEEP_5__

__CAPGO_KEEP_6__

__CAPGO_KEEP_7__

__CAPGO_KEEP_8__

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

setStatsUrl(options)

'setStatsUrl(options)' 제목

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

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

setChannelUrl(options)

'setChannelUrl(options)' 제목

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

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

runtime에서 App ID를 변경하세요.

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

현재 App ID를 가져옵니다.

const appId = await updater.getAppId();

setDebugMenu(options)

setDebug 메뉴 설정하기

Debug 메뉴를 사용하거나 비활성화합니다.

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

클립보드에 복사

const enabled = await updater.isDebugMenuEnabled();

Debug 메뉴 업데이트 이벤트를 듣기 위해

클립보드에 복사

이벤트 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() __CAPGO_KEEP_0__가 호출되었습니다

예시: 전체 이벤트 처리

예시: 전체 이벤트 처리
// 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)
});

Capgo를 사용 중이라면 Electron Updater API 참고문서 API 대시보드와 운영을 계획하고 연결하세요. @capgo/electron-updater를 사용하여 @capgo/electron-updater를 사용하여 Native 기능을 구현하는 경우, API 개요 API 개요에서 구현 세부 정보를 참조하세요. 소개 소개에서 구현 세부 정보를 참조하세요. API 키 API 키에서 구현 세부 정보를 참조하세요. 그리고 기기 기기에서 구현 세부 정보를 참조하세요.