Getting Started
このプラグインのインストール手順と全マークダウンガイドを含む設定の質問をコピーする。
Set up this Capacitor plugin in the project.
Use the package manager already used by the project.
Install these package(s): `@capgo/capacitor-updater`
Run the required Capacitor sync/update step after installation.
Read this markdown guide for the full setup steps: https://raw.githubusercontent.com/Cap-go/website/refs/heads/main/apps/docs/src/content/docs/docs/plugins/updater/getting-started.mdx
Use that guide for platform-specific steps, native file edits, permissions, config changes, imports, and usage setup.
If that guide references other docs pages, read them too.
インストール
「インストール」のセクションbun add @capgo/capacitor-updaterbunx cap syncyarn add @capgo/capacitor-updaterbunx cap syncpnpm add @capgo/capacitor-updaterbunx cap syncbun add @capgo/capacitor-updaterbunx cap syncQuick Start
Quick StartのセクションCapgoの主なユーザー向けの Quickstartガイド CapgoのプラグインのインストールとCapgoのクラウド統合をカバーしています。
このガイドは、Capgoのプラグインの技術的な詳細についての理解や、自社ホストの更新の実装を目的とした高度なユーザー向けのものです。
概要
概要のセクションCapacitor アップデーター プラグインは、Capacitor アプリケーション向けのオーバー・ザ・エア (OTA) アップデートを有効にします。これにより、App Storeのレビューを経ることなく、アプリにアップデートをプッシュできます。
しくみ
しくみのセクション- バンドルダウンロード: プラグインは、ZIPファイルに含まれるWebアセットを含むアップデートバンドルをダウンロードします。
- エクストラクト: バンドルは、デバイスのストレージにエクストラクトされます。
- ホットリロード: アプリは、新しいバンドルに切り替わり、再起動を必要とせずにアップデートされます。
- フォールバック: アップデートが失敗した場合、 アプリは前の正常に動作していたバージョンに戻ります。
Usage Modes
「Usage Modes」のセクション1. Auto-Update Mode (推奨)
「1. Auto-Update Mode (推奨)」のセクション自動更新管理とともにプラグインを使用する最も簡単な方法:
import { CapacitorUpdater } from '@capgo/capacitor-updater';
// Plugin handles everything automatically// Configure in capacitor.config.tsあなたの capacitor.config.ts:
{ plugins: { CapacitorUpdater: { autoUpdate: 'atBackground', updateUrl: 'https://your-update-server.com/api/updates' } }}2. Manual Mode
「2. Manual Mode」のセクションアップデートプロセスに対する高度な制御を必要とする場合:
import { CapacitorUpdater } from '@capgo/capacitor-updater';
// Download an updateconst 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 immediatelyawait CapacitorUpdater.reload();プラットフォーム設定
プラットフォーム設定iOS
iOSプラグインはデフォルトで動作します。追加の設定は必要ありません。
Android
Androidプラグインはデフォルトで動作します。追加の設定は必要ありません。
基本APIの使用
基本APIの使用アップデートをダウンロード
ダウンロードアップデート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 startawait CapacitorUpdater.set({ id: bundle.id});新しいバンドルでリロード
バンドルをリロード// Reload app immediately with new bundleawait 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 progressCapacitorUpdater.addListener('download', (info) => { console.log('Download progress:', info.percent);});
// Listen for download completionCapacitorUpdater.addListener('downloadComplete', (bundle) => { console.log('Download complete:', bundle.version);});
// Listen for update failuresCapacitorUpdater.addListener('updateFailed', (error) => { console.error('Update failed:', error);});
// Listen for successful updatesCapacitorUpdater.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' } }}統合パターン
「統合パターン」Capgo Cloudとともに
「Capgo Cloudとともに」始めるには最も簡単な方法:
// Install the Capgo CLIbun add -g @capgo/cli
// Login to Capgonpx @capgo/cli login
// Upload your first bundlenpx @capgo/cli bundle upload
// The plugin auto-updates from Capgo cloud「 main Quickstartガイド」 詳細については
自社ホストの更新
「自社ホストの更新」Host your own update server:
// Configure your update endpoint{ plugins: { CapacitorUpdater: { autoUpdate: 'atBackground', updateUrl: 'https://your-server.com/api/check-update' } }}Your server should return:
{ "version": "1.0.1", "url": "https://your-server.com/updates/1.0.1.zip"}See Self-Hosted Mode for complete details.
Manual Update Flow
Manual Update FlowComplete control over updates:
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();}Best Practices
「ベスト プラクティス」セクション- 常にアプリが正常に読み込まれた場合に呼び出す
notifyAppReady()アプリが正常に読み込まれたときに呼び出す - テスト更新を徹底して、生産環境にプッシュする前に
- ネットワークエラーの際に適切なエラーハンドリングを実装する
- バージョン番号を一貫して使用する
- ダウンロードが速くなるように、バンドルサイズを小さく保つ
- 更新の成功率を監視する
次のステップ
「次のステップ」セクション- プラグイン API リファレンス API ドキュメントを完了する
- プラグイン設定 - 全ての構成オプション
- イベント - 利用可能な更新イベント
- 自主ホストモード - 自分で更新サーバーを実行
- ローカル開発 - ローカルで更新をテスト
- デバッグ - トラブルシューティングガイド
サポート
- "サポート"のセクション- Known Issues - 共通問題と解決策
- GitHub Discussions - コミュニティサポート
- Discord -リアルタイムチャット
Getting Startedから続けて
セクションのタイトルは「Getting Startedから続けて」Capacitorを使用している場合 Getting Started nativeプラグインの作業を計画するには、__CAPGO_KEEP_0__と__CAPGO_KEEP_1__を接続する Using @capgo/capacitor-updater native機能のための@capgo/capacitor-updaterの使用 Capgo プラグインディレクトリ Capgo プラグインのための製品ワークフロー Capacitor プラグインのCapgo Capacitor プラグインのCapgoの実装詳細 プラグインの追加または更新 __CAPGO_KEEP_0__ プラグインの追加または更新の実装詳細 Ionic Enterprise プラグインの代替 Ionic Enterprise プラグインの代替の製品ワークフロー