メニューに進む

Electron Updater API リファレンス

GitHub

すべての利用可能なメソッド、イベント、設定オプションをドキュメント化しています。

Core Methods

Core Methods

アプリ起動毎に呼び出す必要があります。 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
});

__CAPGO_KEEP_0__

オプション必要説明
url文字列はいダウンロードするためのバンドルURL
version文字列はいバンドルのバージョン識別子
checksumstringなしSHA256のチェックサムによる検証
sessionKeystringなし暗号化されたバンドルのセッションキー

戻り値: BundleInfo オブジェクトに id, version, status

アプリ再起動時に次のバンドルをロードするようにキューします。

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

パラメータ:

オプションタイプ必要説明
id文字列はいバンドル ID をキューに設定

クリップボードにコピー

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

パラメータ:

オプションタイプ必要説明
id文字列はい現在のバンドルでアプリを手動で再読み込みします。

reload()をクリップボードにコピー

await updater.reload();

__CAPGO_KEEP_0__

削除(options)

バンドルをストレージから削除します。

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

パラメータ

オプション必要説明
id文字列はい削除するバンドルID

バンドルをリセットするか、ビルトインバージョンに戻す

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

パラメータ

オプション必要説明
toLastSuccessfulbooleanNotrueの場合、最後の成功バンドルに戻す

Bundle Information

Bundle情報

Bundle情報とネイティブバージョンの情報を取得します。

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

getFailedUpdate()

getFailedUpdate()

最後の失敗したアップデートの情報を取得します (ロールバックのデバッグに役立ちます)。

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

getBuiltinVersion()

getBuiltinVersion()

アプリバイナリに含まれるバージョンを取得します。

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

アップデートチェック

getFailedUpdate()

サーバーから最新の利用可能なバージョンを確認します。

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文字列利用可能なバージョン
checksumstring__CAPGO_KEEP_0__
sessionKeystring__CAPGO_KEEP_0__
errorstring__CAPGO_KEEP_0__
messagestringサーバーメッセージ

チャンネル管理

チャンネル管理

setChannel(オプション)

setChannel(オプション)

__CAPGO_KEEP_0__を特定のチャネルに割り当てます。

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

__CAPGO_KEEP_0__(options)

__CAPGO_KEEP_2__のセクション

__CAPGO_KEEP_0__を解除してデフォルトに戻します。

await updater.unsetChannel();

__CAPGO_KEEP_0__の現在の割り当てを取得します。

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

このアプリの利用可能なチャンネルをすべて表示します。

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

ダウンロード更新の適用時期を制御します。

setMultiDelay(options)

ダウンロード更新の適用時期を制御します: 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' }
]
});

__CAPGO_KEEP_0____CAPGO_KEEP_1__概要
background__CAPGO_KEEP_0__アプリがバックグラウンドに遷移するのを待つ
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' });

実行時で更新サーバーURLを変更します。

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

実行時で統計報告URLを変更します。

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

__CAPGO_KEEP_0__

__CAPGO_KEEP_1__

__CAPGO_KEEP_2__

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

__CAPGO_KEEP_4__

__CAPGO_KEEP_5__

__CAPGO_KEEP_6__

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() 呼び出されました
// 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 リファレンスから続けてのセクション

Electron Updater __CAPGO_KEEP_0__ リファレンスを使用している場合 Electron Updater API リファレンス ダッシュボードと API の計画と実行に使用している場合、API を接続してください Electron Updater capgo を使用して、@capgo/electron-updater Electron Updater capgo のネイティブ機能を使用する場合、@capgo/electron-updater API の概要 API の実装詳細 Introduction for the implementation detail in Introduction, APIの実装詳細については API Keysの実装詳細については デバイス for the implementation detail in Devices.