__CAPGO_KEEP_0__ - __CAPGO_KEEP_1__ アプリ用のリアルタイム更新

Getting Started

GitHub

AIアシストされたセットアップを使用してプラグインをインストールできます。AIツールに次のコマンドを使用してCapgoスキルを追加します。

ターミナル画面
npx skills add https://github.com/Cap-go/capgo-skills --skill capacitor-plugins

次に、以下のプロンプトを使用してください。

Use the `capacitor-plugins` skill from `Cap-go/capgo-skills` to install the `@capgo/capacitor-updater` plugin in my project.

Manual Setupを使用する場合は、以下のコマンドを実行してプラットフォーム固有の指示を参照してください。

ターミナルウィンドウ
bun add @capgo/capacitor-updater
bunx cap sync

大多数ユーザーにとって、プラグインのインストールと__CAPGO_KEEP_0__クラウド統合の両方をカバーする主なQuickstartガイドを実行することをお勧めします。 このガイドは、主なQuickstartガイドとは異なり、技術的なプラグインの詳細に焦点を当てており、内部メカニズムを理解したり、自社ホストの更新を実装したりしたい高度なユーザー向けです。 which covers both the plugin installation and Capgo cloud integration.

「概要」セクション

For most users, we recommend following the

main Quickstart guide

The Capacitor アップデーター プラグインは、Capacitor アプリケーション向けのオーバー・ザ・エア (OTA) アップデートを有効にします。この機能により、App Storeのレビュー手順を経ることなく、アプリにアップデートをプッシュできます。

  1. Bundle Download: プラグインは、ZIPファイルに含まれるウェブアセットを含むアップデートバンドルをダウンロードします。
  2. Extraction: バンドルは、デバイスのストレージに抽出されます。
  3. Hot Reload: アプリは、新しいバンドルに切り替わり、再起動が必要なくなる。
  4. Fallback: アップデートが失敗した場合、アプリは前の正常に動作していたバージョンに戻ります。

Usage Modes

使用方法
1. 自動更新モード (推奨)

自動更新を管理するための自動更新モードで、最も簡単な方法です。

import { CapacitorUpdater } from '@capgo/capacitor-updater';
// Plugin handles everything automatically
// Configure in capacitor.config.ts

__CAPGO_KEEP_0__ capacitor.config.ts:

{
plugins: {
CapacitorUpdater: {
autoUpdate: 'atBackground',
updateUrl: 'https://your-update-server.com/api/updates'
}
}
}

2. 手動モード

2. 手動モード

更新プロセスの高度な制御を実現するために使用します。

import { CapacitorUpdater } from '@capgo/capacitor-updater';
// Download an update
const bundle = await CapacitorUpdater.download({
url: 'https://your-server.com/updates/v1.0.1.zip',
version: '1.0.1'
});
// Set the bundle (will be used on next app start)
await CapacitorUpdater.set({
id: bundle.id
});
// Or reload immediately
await CapacitorUpdater.reload();

プラットフォーム設定

プラットフォーム設定

追加の設定は必要ありません。プラグインは箱から出てきます。

追加の設定は必要ありません。プラグインは箱から出てきます。

import { CapacitorUpdater } from '@capgo/capacitor-updater';
const bundle = await CapacitorUpdater.download({
url: 'https://example.com/update.zip',
version: '1.0.1'
});
console.log('Downloaded bundle:', bundle.id);
// Set bundle to be used on next app start
await CapacitorUpdater.set({
id: bundle.id
});
// Reload app immediately with new bundle
await CapacitorUpdater.reload();
const { bundles } = await CapacitorUpdater.list();
console.log('Available bundles:', bundles);
await CapacitorUpdater.delete({
id: 'bundle-id'
});

現在のバンドルを取得

現在のバンドルを取得
const { bundle } = await CapacitorUpdater.current();
console.log('Current bundle:', bundle.version);

イベントリスナー

イベントリスナー

更新イベントをリスンする

import { CapacitorUpdater } from '@capgo/capacitor-updater';
// Listen for download progress
CapacitorUpdater.addListener('download', (info) => {
console.log('Download progress:', info.percent);
});
// Listen for download completion
CapacitorUpdater.addListener('downloadComplete', (bundle) => {
console.log('Download complete:', bundle.version);
});
// Listen for update failures
CapacitorUpdater.addListener('updateFailed', (error) => {
console.error('Update failed:', error);
});
// Listen for successful updates
CapacitorUpdater.addListener('updateAvailable', (info) => {
console.log('Update available:', info.version);
});

設定オプション

設定オプション

プラグインをあなたの capacitor.config.ts:

{
plugins: {
CapacitorUpdater: {
// Auto-update settings
autoUpdate: 'atBackground',
updateUrl: 'https://api.example.com/updates',
// Update behavior
resetWhenUpdate: true,
// Version settings
version: '1.0.0',
// Security
allowModifyUrl: false,
// Stats collection
statsUrl: 'https://api.example.com/stats',
// Channel (for Capgo cloud)
defaultChannel: 'production'
}
}
}

The easiest way to get started:

// Install the Capgo CLI
bun add -g @capgo/cli
// Login to Capgo
npx @capgo/cli login
// Upload your first bundle
npx @capgo/cli bundle upload
// The plugin auto-updates from Capgo cloud

See the main Quickstart guide for details.

Host your own update server:

// Configure your update endpoint
{
plugins: {
CapacitorUpdater: {
autoUpdate: 'atBackground',
updateUrl: 'https://your-server.com/api/check-update'
}
}
}

サーバーは次の値を返す必要があります。

{
"version": "1.0.1",
"url": "https://your-server.com/updates/1.0.1.zip"
}

See Self-Hosted Mode 詳細は「Self-Hosted Mode」でご確認ください。

更新の完全な制御:

import { CapacitorUpdater } from '@capgo/capacitor-updater';
async function checkAndUpdate() {
// Check for updates from your server
const response = await fetch('https://api.example.com/check-update');
const { version, url } = await response.json();
// Download the update
const bundle = await CapacitorUpdater.download({
url,
version
});
// Notify bundle is ready
await CapacitorUpdater.notifyAppReady();
// Set as next version
await CapacitorUpdater.set({ id: bundle.id });
// Reload when ready
await CapacitorUpdater.reload();
}
  • 常に呼び出す notifyAppReady() アプリが正常に読み込まれたとき
  • 生産環境にプッシュする前に、テストを徹底的に行ってください
  • ネットワークエラーの際に適切なエラーハンドリングを実装してください
  • バージョン番号を一貫して使用してください
  • ダウンロードが速くなるように、バンドルサイズを小さくしてください
  • アップデートの成功率を監視してください

次のステップ

「次のステップ」

当前に設定です。コンタイントを为いに定义しています

コンタイントを为いに定义しています

コンタイントを为いに定义しています コンタイントを为いに定义しています コンタイントを为いに定义しています。コンタイントを为いに定义しています Using @capgo/capacitor-updater for the native capability in Using @capgo/capacitor-updater, Capgo Plugin Directory 製品ワークフローについての情報は、Capgo プラグインディレクトリで確認できます。 Capacitor プラグインは、Capgo によって提供されています。 for the implementation detail in Capacitor Plugins by Capgo, プラグインの追加または更新 製品ワークフローについての情報は、プラグインの追加または更新で確認できます。 Ionic Enterprise プラグインの代替 製品ワークフローについての情報は、Ionic Enterprise プラグインの代替で確認できます。