メニューに進む

Getting Started

GitHub

Install

Install

You can use our AI-Assisted Setup to install the plugin. Add the Capgo skills to your AI tool using the following command:

Terminal window
npx skills add https://github.com/Cap-go/capgo-skills --skill capacitor-plugins

Installを実行することができます。AI-Assisted Setupを使用してプラグインをインストールすることができます。AIツールに__CAPGO_KEEP_0__スキルを追加するには、以下のコマンドを使用してください:

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

この手順では、プラットフォーム固有の指示を以下に従って、プラグインをインストールすることができます。

ターミナル画面
bun add @capgo/capacitor-webview-guardian
bunx cap sync
import { WebviewGuardian } from '@capgo/capacitor-webview-guardian';

フォアグラウンドイベントを監視し、自動的に WebView の健康状態を確認します。

import { WebviewGuardian } from '@capgo/capacitor-webview-guardian';
await WebviewGuardian.startMonitoring();

自動前景監視を停止します。

import { WebviewGuardian } from '@capgo/capacitor-webview-guardian';
await WebviewGuardian.stopMonitoring();

最新の監視状態を取得します。

import { WebviewGuardian } from '@capgo/capacitor-webview-guardian';
await WebviewGuardian.getState();

ウェブビューのヘルスプローブを即座に実行します。

import { WebviewGuardian } from '@capgo/capacitor-webview-guardian';
await WebviewGuardian.checkNow();
export interface StartMonitoringOptions {
/**
* Delay (in ms) before running a health check after the app re-enters the foreground.
* Defaults to 600ms to let the bridge finish resuming.
*/
foregroundDebounceMs?: number;
/**
* Script executed via `evaluateJavascript`/`evaluateJavaScript` to confirm the WebView is alive.
* Defaults to `document.readyState`.
*/
pingScript?: string;
/**
* Automatically reloads the WebView when a terminated render process is detected.
* Disable to receive `webviewCrashed` events and restart manually.
*/
autoRestart?: boolean;
/**
* Strategy used when restarting the WebView. Defaults to `reload`.
*/
restartStrategy?: RestartStrategy;
/**
* Custom HTTPS/HTTP URL to load when `restartStrategy` is `customUrl`.
*/
customRestartUrl?: string;
/**
* Emits verbose logging in the native layer when true.
*/
debug?: boolean;
/**
* Whether an immediate health check should be executed right after enabling monitoring.
* Defaults to `true`.
*/
runInitialCheck?: boolean;
}
export interface GuardianState {
monitoring: boolean;
reason: string;
timestamp: string;
lastHealthyAt?: string;
lastRestartAt?: string;
lastCrashAt?: string;
pendingRestartReason?: string;
error?: string;
}
export interface CheckNowOptions {
/**
* Text tag describing why a manual check is being requested.
*/
reason?: string;
}
export interface CheckResult {
healthy: boolean;
restarted: boolean;
reason: string;
timestamp: string;
error?: string;
pendingRestart?: boolean;
}
export type GuardianEvent = GuardianState;
export type RestartStrategy = 'reload' | 'reloadFromOrigin' | 'customUrl';

ソース オブ トゥース

Source Of Truth

プラグインの生成されたページです src/definitions.tspublic APIがアップストリームで変更された場合に、再度Syncを実行してください

Getting Startedから続けてください

Getting Startedから続けてください

Capacitorを使用している場合 Getting Started nativeメディアとインターフェイスの動作を計画するには、Capacitorを @capgo/capacitor-webview-guardian native機能のCapacitorを使用する場合、@capgo/capacitor-webview-guardian @capgo/capacitor-live-activities native機能のCapacitorを使用する場合、@capgo/capacitor-live-activities @capgo/capacitor-live-activities 実装詳細については @capgo/capacitor-live-activities を参照してください。 Using @capgo/capacitor-video-player Using @capgo/capacitor-video-player のネイティブ機能については、 @capgo/capacitor-video-player 実装詳細については @capgo/capacitor-video-player を参照してください。