Mulai Berlatih
Copy prompt pengaturan dengan langkah instalasi dan panduan markdown lengkap untuk plugin ini.
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.
Pasang
Judul Bagian “Pasang”bun add @capgo/capacitor-webview-crashbunx cap syncImpor
Judul Bagian “Impor”import { WebViewCrash } from '@capgo/capacitor-webview-crash';Alur Pemulihan yang Disarankan
Judul Bagian “Alur Pemulihan yang Disarankan”Lampirkan pemangku jawab secepat mungkin pada awal mulai aplikasi Anda agar runtime yang dipulihkan dapat bereaksi sebelum pengguna melanjutkan navigasi:
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 ringkasan
Ringkasan APIgetPendingCrashInfo
Ringkasan titled “getPendingCrashInfo”Mengembalikan marker kecelakaan native yang disimpan, atau null ketika tidak ada yang menunggu.
const pending = await WebViewCrash.getPendingCrashInfo();if (pending.value) { console.log(pending.value.platform, pending.value.reason);}clearPendingCrashInfo
Ringkasan titled “clearPendingCrashInfo”Menghapus marker kecelakaan yang disimpan setelah proses pemulihan Anda selesai.
await WebViewCrash.clearPendingCrashInfo();simulateCrashRecovery
Ringkasan titled “simulateCrashRecovery”Membuat marker kecelakaan palsu sehingga QA dan debugging lokal dapat menguji jalur pemulihan tanpa membuat WebView nyata mengalami kecelakaan.
const simulated = await WebViewCrash.simulateCrashRecovery();console.log(simulated.value);Catatan platform
Catatan Platform- Android menyimpan metadata kejadian crash dari
onRenderProcessGone, termasukdidCrashdanrendererPriorityAtExitketika platform menyediakannya. - iOS menyimpan metadata kejadian crash dari
webViewWebContentProcessDidTerminatedan menambahkan status aplikasi saat ini ketika tersedia. - Web tidak mendeteksi crash renderer yang sebenarnya. Implementasi web hanya menyimulasikan perilaku dengan menggunakan penyimpanan lokal.
Referensi Tipe
Catatan PlatformPendingCrashInfoResult
Catatan Tipeexport interface PendingCrashInfoResult { /** * Stored crash metadata, or `null` when no marker is pending. */ value: WebViewCrashInfo | null;}WebViewCrashInfo
Bagian berjudul “Informasi Kecelakaan WebView”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
Bagian berjudul “Platform Kecelakaan WebView”export type WebViewCrashPlatform = 'android' | 'ios' | 'web';WebViewCrashReason
Bagian berjudul “Alasan Kecelakaan WebView”export type WebViewCrashReason = 'renderProcessGone' | 'webContentProcessDidTerminate' | 'simulated';WebViewCrashAppState
Bagian berjudul “Status Aplikasi Kecelakaan WebView”export type WebViewCrashAppState = 'active' | 'inactive' | 'background' | 'unknown';Sumber Kebenaran
Bagian berjudul “Sumber Kebenaran”Halaman ini dihasilkan dari plugin’s src/definitions.ts. Re-run sinkronisasi ketika API publik berubah di atas.