コンテンツにジャンプ

はじめに

GitHub

インストール

インストール

CapgoのAIアシスタントセットアップを使用してプラグインをインストールできます。AIツールにCapgoスキルを追加するには、以下のコマンドを実行してください。

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

CapgoのマーケティングウェブサイトのUIラベルです。ページエージェントのスラッグを表示します。

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

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

ターミナル画面
bun add @capgo/capacitor-updater
bunx cap sync

クイックスタート

Quick Start

主なユーザー向けの 主なQuickstartガイド 主なQuickstartガイドでは、プラグインのインストールとCapgoクラウド統合をカバーしています。

このガイドでは、advancedユーザー向けに、プラグインの技術的な詳細と、自社で更新を実装するためのメカニズムについて説明しています。

概要

概要

The Capacitor Updater plugin enables over-the-air (OTA) updates for your Capacitor applications. This allows you to push updates to your app without going through app store reviews.

機能のしくみ

機能のしくみ
  1. バンドルダウンロード: プラグインは、更新バンドル(ZIPファイルに含まれるWebアセット)をダウンロードします
  2. 抽出: Bundlesはデバイスのストレージに抽出されます
  3. ホットリロード: アプリは新しいバンドルに切り替わり、再起動が必要なくなる
  4. フォールバック: アップデートが失敗した場合、アプリは前の正常に動作していたバージョンに戻ります

自動更新管理とともにプラグインを使用する最も簡単な方法:

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

Capgoに追加する capacitor.config.ts:

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

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

プラットフォーム設定

2. 手動モード

Android

Android

Android

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

基本的なAPIの使用

基本的なAPIの使用

アップデートのダウンロード

基本的な__CAPGO_KEEP_0__の使用
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'
}
}
}

統合パターン

統合パターン

「Capgo Cloud」

「Capgo Cloud」

始めるには、簡単な方法があります:

// 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 メイン Quickstart ガイド 詳細を参照してください。

セルフホストアップデート

セクション「自主ホストの更新」

サーバーを自宅でホストする

// 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 セルフホスト モード 完全な詳細についてはこちら。

アップデートの完全な制御:

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() アプリが正常に起動したときに呼び出す
  • テストアップデートを徹底的に行う前に、生産環境にプッシュする
  • ネットワークエラーのための適切なエラーハンドリングを実装する
  • バージョン番号を一貫して使用する
  • 高速ダウンロードのためにバンドルサイズを小さく保つ
  • アップデート成功率の監視

次のステップ

次のステップ

サポート

サポート

もしCapgoを使用している場合 Getting Started を使用して Using @capgo/capacitor-updater Using @capgo/capacitor-updater native capabilityを使用するには、Using @Capgo/__CAPGO_KEEP_1__-updaterを使用します。 Capgo Plugin Directory Capacitor Capgo プラグイン Capacitor Plugins by Capgo implementation detailを使用するには、__CAPGO_KEEP_0__ Plugins by __CAPGO_KEEP_1__を使用します。 Adding or Updating Plugins Ionic Enterprise プラグイン代替 Ionic Enterprise プラグインの製品ワークフロー向け