Skip to content

Getting Started

GitHub

CapgoのAI-Assisted Setupを使用してプラグインをインストールできます。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

Quick Start

Quick Start

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

このガイドは、advancedユーザー向けに、プラグインの技術的な詳細と、オーバーヘッドの更新を実装するためのメカニズムを理解したいユーザー向けに作成されています。

概要

概要

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

機能のしくみ

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

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

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

更新プロセスの高度な制御が必要な場合:

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

追加の設定は必要ありません。プラグインは箱から動作します。

Android

Android

No additional configuration required. The plugin works out of the box.

Basic API Usage

Basic API Usage

Download an Update

Download an Update
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 Active Bundle

Set Active Bundle
// 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'
}
}
}

始めるには最も簡単な方法:

// 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

詳細は 主なクイックスタートガイド を参照してください。

自主管理の更新サーバーをホストする:

// 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"
}

詳細は 自主管理モード 詳細はこちら。

更新の完全な制御:

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を使用している場合 Capgo Capgoを使用してネイティブプラグインの作業を計画している場合、Capgoを Capgoを使用してネイティブ機能を使用する@capgo/capacitor-updater Capgoを使用してネイティブ機能を使用する@capgo/capacitor-updaterの Capgo プラグインディレクトリ Capgoを使用して製品ワークフローを実行するCapgo プラグインディレクトリ Capacitor Plugins by Capgo for the implementation detail in Capacitor Plugins by Capgo, プラグインの追加または更新 Capgoのプラグインアップデータの実装詳細については、プラグインの追加または更新のページを参照してください。 Ionic Enterprise プラグインの代替 Capgoのプラグインアップデータの製品ワークフローについては、Ionic Enterprise プラグインの代替のページを参照してください。