내용으로 건너뛰기

시작하기

GitHub

설치

설치

AI-Assisted 설치를 사용하여 플러그인을 설치할 수 있습니다. 다음 명령어를 사용하여 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-webview-guardian` plugin in my project.

만약 Manual Setup을 선호한다면, 플러그인을 설치하기 위해 다음 명령어를 실행하고 아래의 플랫폼별 지침을 따르세요:

터미널 창
bun add @capgo/capacitor-webview-guardian
bunx cap sync
import { WebviewGuardian } from '@capgo/capacitor-webview-guardian';

startMonitoring

startMonitoring

앞면 이벤트를 관찰하고 WebView의 건강을 자동으로 확인합니다.

import { WebviewGuardian } from '@capgo/capacitor-webview-guardian';
const result = await WebviewGuardian.startMonitoring();
console.log(result);

stopMonitoring

stopMonitoring

앞면 자동 모니터링을 중지합니다.

import { WebviewGuardian } from '@capgo/capacitor-webview-guardian';
const result = await WebviewGuardian.stopMonitoring();
console.log(result);

getState

getState

최근 모니터링 상태를 반환합니다.

import { WebviewGuardian } from '@capgo/capacitor-webview-guardian';
const result = await WebviewGuardian.getState();
console.log(result);

checkNow

checkNow

WebView 건강 검사를 즉시 강제합니다.

import { WebviewGuardian } from '@capgo/capacitor-webview-guardian';
const result = await WebviewGuardian.checkNow();
console.log(result);

타입 참조

타입 참조

StartMonitoringOptions

모니터링 옵션 시작
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;
}

GuardianState

감시자 상태
export interface GuardianState {
monitoring: boolean;
reason: string;
timestamp: string;
lastHealthyAt?: string;
lastRestartAt?: string;
lastCrashAt?: string;
pendingRestartReason?: string;
error?: string;
}

CheckNowOptions

체크 옵션
export interface CheckNowOptions {
/**
* Text tag describing why a manual check is being requested.
*/
reason?: string;
}

CheckResult

체크 결과
export interface CheckResult {
healthy: boolean;
restarted: boolean;
reason: string;
timestamp: string;
error?: string;
pendingRestart?: boolean;
}

GuardianEvent

감시자 이벤트
export type GuardianEvent = GuardianState;
export type RestartStrategy = 'reload' | 'reloadFromOrigin' | 'customUrl';

이 페이지는 플러그인의 소스 코드에서 생성됩니다. src/definitions.ts공개 API이 업스트림에서 변경될 때 다시 싱크를 실행하세요.

시작하기

시작하기

이 플러그인을 사용하는 경우 시작하기 자연적인 미디어 및 인터페이스 동작을 계획하기 위해, 그것을 Capgo @capgo/capacitor-webview-guardian Capgo @capgo/capacitor-webview-guardian Capgo @capgo/capacitor-live-activities Capgo @capgo/capacitor-live-activities Capgo @capgo/capacitor-live-activities Capgo @capgo/capacitor-live-activities Capgo @capgo/capacitor-video-player Capgo @capgo/capacitor-video-player Capgo @capgo/capacitor-video-player Capgo @capgo/capacitor-video-player