Getting Started
Copia un prompt di configurazione con i passaggi di installazione e la guida markdown completa per questo plugin.
Set up this Capacitor plugin in the project.
Use the package manager already used by the project.
Install these package(s): `@capgo/capacitor-webview-guardian`
Run the required Capacitor sync/update step after installation.
Read this markdown guide for the full setup steps: https://raw.githubusercontent.com/Cap-go/website/refs/heads/main/apps/docs/src/content/docs/docs/plugins/webview-guardian/getting-started.mdx
Use that guide for platform-specific steps, native file edits, permissions, config changes, imports, and usage setup.
If that guide references other docs pages, read them too.
Puoi utilizzare la nostra configurazione assistita dall'IA per installare il plugin. Aggiungi le Capgo competenze al tuo strumento di AI utilizzando il seguente comando:
npx skills add https://github.com/Cap-go/capgo-skills --skill capacitor-pluginsPoi utilizza la seguente richiesta:
Use the `capacitor-plugins` skill from `Cap-go/capgo-skills` to install the `@capgo/capacitor-webview-guardian` plugin in my project.Se preferisci l'installazione manuale, installa il plugin eseguendo i seguenti comandi e segui le istruzioni specifiche per la piattaforma riportate di seguito.
bun add @capgo/capacitor-webview-guardianbunx cap syncImporta
Sezione intitolata “Importa”import { WebviewGuardian } from '@capgo/capacitor-webview-guardian';API Overview
Sezione intitolata “API Overview”startMonitoring
Sezione intitolata “startMonitoring”Inizia l'osservazione degli eventi in primo piano e controlla automaticamente la salute del WebView.
import { WebviewGuardian } from '@capgo/capacitor-webview-guardian';
const result = await WebviewGuardian.startMonitoring();console.log(result);stopMonitoring
Sezione intitolata “stopMonitoring”Arresta ogni monitoraggio di foreground automatico.
import { WebviewGuardian } from '@capgo/capacitor-webview-guardian';
const result = await WebviewGuardian.stopMonitoring();console.log(result);Restituisce lo stato di monitoraggio più recente conosciuto.
import { WebviewGuardian } from '@capgo/capacitor-webview-guardian';
const result = await WebviewGuardian.getState();console.log(result);Esegue un probe di salute del WebView immediatamente.
import { WebviewGuardian } from '@capgo/capacitor-webview-guardian';
const result = await WebviewGuardian.checkNow();console.log(result);Tipo di Riferimento
Sottosezione intitolata “Tipo di Riferimento”StartMonitoringOptions
Sottosezione intitolata “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
Sezione intitolata “StatoGuardiano”export interface GuardianState { monitoring: boolean; reason: string; timestamp: string; lastHealthyAt?: string; lastRestartAt?: string; lastCrashAt?: string; pendingRestartReason?: string; error?: string;}CheckNowOptions
Sezione intitolata “Opzioni di controllo ora”export interface CheckNowOptions { /** * Text tag describing why a manual check is being requested. */ reason?: string;}CheckResult
Sezione intitolata “Risultato di controllo”export interface CheckResult { healthy: boolean; restarted: boolean; reason: string; timestamp: string; error?: string; pendingRestart?: boolean;}GuardianEvent
Sezione intitolata “Evento del guardiano”export type GuardianEvent = GuardianState;RestartStrategy
Sezione intitolata “Strategia di riavvio”export type RestartStrategy = 'reload' | 'reloadFromOrigin' | 'customUrl';Fonte di verità
Sezione intitolata “Fonte di verità”Questa pagina è generata dal plugin's src/definitions.ts. Re-run the sync when the public API changes upstream.
Keep going from Getting Started
Sezione intitolata “Prosegui da Inizia”Se stai utilizzando Getting Started per pianificare il comportamento dei media nativi e dell'interfaccia, connettilo con Utilizza @capgo/capacitor-webview-guardian per la capacità nativa in Utilizza @capgo/capacitor-webview-guardian Utilizza @capgo/capacitor-live-activities per la capacità nativa in Utilizza @capgo/capacitor-live-activities @capgo/capacitor-attività-in-vivo per i dettagli di implementazione in @capgo/capacitor-live-attivitàs Utilizzando @capgo/capacitor-player-video per la capacità nativa in Utilizzando @capgo/capacitor-player-video, e @capgo/capacitor-player-video per i dettagli di implementazione in @capgo/capacitor-player-video.