メインコンテンツにスキップ

始めてから

Install

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

Import

Import
import { WebviewGuardian } from '@capgo/capacitor-webview-guardian';

startMonitoring

startMonitoring

Foregroundイベントを監視し、自動的に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';

真実の源

「真実の源」

このページはプラグインの src/definitions.ts公開 API がアップストリームで変更された場合に再度 Sync を実行してください。

Getting Started から続けてください

「Getting Started から続けてください」

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