Démarrage
Copiez une invite de configuration avec les étapes d'installation et le guide markdown complet pour ce 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-crash`
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-crash/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.
Installation
Section intitulée “Installation”bun add @capgo/capacitor-webview-crashbunx cap syncImporter
Section intitulée “Importer”import { WebViewCrash } from '@capgo/capacitor-webview-crash';Flux de récupération recommandé
Section intitulée “Flux de récupération recommandé”Attachez l'écouteur aussi tôt que possible dans le démarrage de votre application afin que le runtime récupéré puisse réagir avant que les utilisateurs continuent de naviguer :
import { WebViewCrash } from '@capgo/capacitor-webview-crash';
await WebViewCrash.addListener('webViewRestoredAfterCrash', async (info) => { console.log('Recovered after a WebView crash', info);
// Rehydrate critical state, reopen the correct screen, or prompt the user to retry. await WebViewCrash.clearPendingCrashInfo();});
const pending = await WebViewCrash.getPendingCrashInfo();// Note: the listener callback may have already cleared the pending marker.if (pending.value) { console.log('Pending crash marker', pending.value);}API : Présentation
Résumé de APIgetPendingCrashInfo
Section intitulée “getPendingCrashInfo”Renvoie le marqueur de crash natif stocké, ou null lorsqu'il n'y a rien en attente.
const pending = await WebViewCrash.getPendingCrashInfo();if (pending.value) { console.log(pending.value.platform, pending.value.reason);}clearPendingCrashInfo
Section intitulée “clearPendingCrashInfo”Efface le marqueur de crash stocké après que votre gestion de récupération est terminée.
await WebViewCrash.clearPendingCrashInfo();simulateCrashRecovery
Section intitulée “simulateCrashRecovery”Crée un marqueur de crash fictif afin que les équipes QA et de débogage local puissent exercer le chemin de récupération sans faire crasher une vraie WebView.
const simulated = await WebViewCrash.simulateCrashRecovery();console.log(simulated.value);Notes de plateforme
Remarques sur la plateforme- Android enregistre les métadonnées de crash à partir de
onRenderProcessGone, y comprisdidCrashetrendererPriorityAtExitlorsque la plateforme les fournit. - iOS enregistre les métadonnées de crash à partir de
webViewWebContentProcessDidTerminateet ajoute l'état actuel de l'application lorsque disponible. - La version Web ne détecte pas les crashs de rendu réel. La mise en œuvre Web ne simule que le comportement avec le stockage local.
Référence de type
Remarques sur la plateformePendingCrashInfoResult
Référence de typeexport interface PendingCrashInfoResult { /** * Stored crash metadata, or `null` when no marker is pending. */ value: WebViewCrashInfo | null;}WebViewCrashInfo
Section intitulée « WebViewCrashInfo »export interface WebViewCrashInfo { /** * Platform that detected and stored the crash marker. */ platform: WebViewCrashPlatform;
/** * Unix timestamp in milliseconds for when the crash marker was written. */ timestamp: number;
/** * ISO-8601 version of `timestamp`. */ timestampISO: string;
/** * Platform-specific reason for the crash marker. */ reason: WebViewCrashReason;
/** * Last known WebView URL when the crash marker was written. */ url?: string;
/** * Android-only hint from `RenderProcessGoneDetail.didCrash()`. */ didCrash?: boolean;
/** * Android-only renderer priority reported at exit. */ rendererPriorityAtExit?: number;
/** * iOS-only application state captured when the WebView process died. */ appState?: WebViewCrashAppState;}WebViewCrashPlatform
Section intitulée « WebViewCrashPlatform »export type WebViewCrashPlatform = 'android' | 'ios' | 'web';WebViewCrashReason
Section intitulée « WebViewCrashReason »export type WebViewCrashReason = 'renderProcessGone' | 'webContentProcessDidTerminate' | 'simulated';WebViewCrashAppState
Section intitulée « WebViewCrashAppState »export type WebViewCrashAppState = 'active' | 'inactive' | 'background' | 'unknown';Source De Vérité
Section intitulée « Source De Vérité »Cette page est générée à partir du plugin’s src/definitions.tsRe-run the sync when the public API changes upstream.