メインコンテンツにジャンプ

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文字列はいダウンロードするためのバンドルURL
version文字列はいバンドルのバージョン識別子
checksum日本語なしSHA256のチェックサムの検証用
sessionKeyなしセッション キーで暗号化されたバンドルの場合戻り値:

オブジェクトに BundleInfo next(options)のセクション id, version, status

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

クリップボードにコピー

__CAPGO_KEEP_0__

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

Parameters:

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

アプリをすぐにバンドルに切り替え、再読み込みする

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

パラメータ:

オプションタイプ必要説明
id文字列はいアプリを再起動するためのバンドルID

クリップボードにコピー

await updater.reload();

__CAPGO_KEEP_0__

__CAPGO_KEEP_1__

__CAPGO_KEEP_2__

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

__CAPGO_KEEP_4__

__CAPGO_KEEP_5____CAPGO_KEEP_6____CAPGO_KEEP_7____CAPGO_KEEP_8__
id__CAPGO_KEEP_9____CAPGO_KEEP_10____CAPGO_KEEP_11__

バンドルバージョンまたは最後の成功バンドルにリセットします。

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

パラメータ:

オプションタイプ必要説明
toLastSuccessfulbooleanNotrueの場合、最後の成功バンドルにリセットする代わりにバンドルバージョンにリセットします。

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

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

戻り値:

プロパティタイプ説明
url文字列ダウンロード URL (更新なしの場合空)
version利用可能なバージョン__CAPGO_KEEP_0__
checksumstringSHA256のチェックサム
sessionKeystring暗号化セッションキー
errorstringチェックが失敗した場合のエラーメッセージ
messagestringサーバーメッセージ

チャンネル管理

チャンネル管理

setChannel(options)

setChannel(options)

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

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

__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']

ダウンロードした更新を適用するタイミングを制御します。

更新が適用される前に満たす必要がある条件を設定します。

// 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__CAPGO_KEEP_0__アプリがバックグラウンドに遷移するのを待つ
kill-アプリが終了し再起動されるのを待つ
dateISO形式の日付文字列特定の日時まで待つ
nativeVersionバージョン文字列ネイティブアプリの更新を待つ

すべての遅延条件をクリアし、次のチェックで即時更新を適用する

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

チャンネル管理URLを変更します。

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

実行時App IDを変更します。

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

現在のアプリIDを取得します。

const appId = await updater.getAppId();

デバッグメニューを有効または無効にします。

Section titled “setDebugMenu(options)”

クリップボードにコピー

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

Section titled “isDebugMenuEnabled()”

デバッグメニューの有効状態を確認します。

デバッグ メニューが有効かどうかを確認します。

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

Electron Updater API リファレンスから続ける

Electron Updater API リファレンスから続ける

Capgo を使用している場合 Electron Updater API リファレンス ダッシュボードと API の作業を計画する場合、Capgo を使用して接続してください。 Capgo を使用して、@capgo/electron-updater を使用してネイティブ機能を実装する Capgo を使用して、@capgo/electron-updater の実装詳細を実装する Capgo を使用して、API の概要を実装する Capgo を使用して、API の実装詳細を実装する 概要 概要の実装詳細について API キー API キーの実装詳細について デバイス デバイスの実装詳細について