@capgo/capacitor-웹뷰 충돌 사용
웹뷰 충돌을 감지하고 iOS 및 Android에서 죽은 웹뷰를 재시작하고, 일주일 이상 실행되는 웹뷰를 일정 주기로 재활용합니다.
설치
npm install @capgo/capacitor-webview-crash
npx cap sync
이 플러그인이 제공하는 것
- iOS 및 Android에서 웹뷰 충돌 후 네이티브 재시작.
- 키오스크, POS, 전광판, 스캐너 및 데스크톱 앱을 위한 일주일 이상 실행되는 웹뷰에 대해 고정 간격으로 네이티브 웹뷰 재시작.
restartWebView- JavaScript가 페이지 리로드 없이 새로운 네이티브 웹뷰를 요청할 수 있습니다.WebViewCrashPluginConfig- 유형plugins.WebViewCrashoption incapacitor.config.ts.getPendingCrashInfo- 네이티브 충돌 또는 재시작 마커를 저장하거나 반환합니다.null__CAPGO_KEEP_0__clearPendingCrashInfo__CAPGO_KEEP_1__simulateCrashRecovery__CAPGO_KEEP_2__webViewRestoredAfterCrash__CAPGO_KEEP_3__webViewRestoredAfterRestart__CAPGO_KEEP_4__
__CAPGO_KEEP_5__
import { WebViewCrash } from '@capgo/capacitor-webview-crash';
await WebViewCrash.addListener('webViewRestoredAfterCrash', async (info) => {
console.log('Recovered after a WebView crash', info);
await WebViewCrash.clearPendingCrashInfo();
});
await WebViewCrash.addListener('webViewRestoredAfterRestart', async (info) => {
console.log('Recovered after a native WebView restart', info);
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 or restart marker', pending.value);
}
__CAPGO_KEEP_6__
__CAPGO_KEEP_7__ capacitor.config.ts __CAPGO_KEEP_8__
import type { CapacitorConfig } from '@capacitor/cli';
import type { WebViewCrashPluginConfig } from '@capgo/capacitor-webview-crash';
const webViewCrash: WebViewCrashPluginConfig = {
restartOnCrash: true,
restartCron: '0 3 * * *',
restartAfterCrashDelayMs: 0,
};
const config: CapacitorConfig = {
plugins: {
WebViewCrash: webViewCrash,
},
};
export default config;
__CAPGO_KEEP_9__ reason: 'periodicRestart'__CAPGO_KEEP_10__ restartIntervalMs __CAPGO_KEEP_11__ restartCron 5개의 장치 지역 시간대 내 크론 스케줄을 위한 0 3 * * * 일정 03:00 재시작. 두 가지 스케줄을 동시에 구성하지 마세요: native 초기화는 restartCron 이 설정이 restartIntervalMs 보다 클 때 치명적인 config 오류를 발생시킵니다. 0중요한 앱 상태를 저장한 후 짧은 스케줄을 사용하세요.
수동 네이티브 재시작
JavaScript가 네이티브 WebView를 미리 교체해야 할 때 호출하세요: 예를 들어, 메모리 집약적인 워크플로우 후: restartWebView() 메서드는
await WebViewCrash.restartWebView();
를 작성하고 네이티브 reason: 'manualRestart' and asks native code to create a fresh WebView. Android recreates the host activity. iOS rebuilds the Capacitor bridge view so a new WKWebView 브리지를 다시 생성하여 새로운
를 생성하는 대신 현재 페이지를 다시 로드하지 않습니다.
- GitHub: https://github.com/Cap-go/capacitor-webview-crash/
- 문서: /docs/plugins/webview-crash/
Using @capgo/capacitor-webview-crash에서 계속하세요.
__CAPGO_KEEP_2__이 __CAPGO_KEEP_1__을 사용하고 있다면 Using @capgo/capacitor-webview-crash __CAPGO_KEEP_1__을 사용하여 @capgo/capacitor-webview-crash for the implementation detail in @capgo/capacitor-webview-crash, Getting Started Getting Started의 구현 세부 사항을 확인하세요. capgo/capacitor-live-activities를 사용하여 native 기능을 사용하는 @capgo/capacitor-live-activities @capgo/capacitor-live-activities implementation 세부 정보를 사용하는 @capgo/capacitor-live-activities, native 기능을 사용하는 @capgo/capacitor-video-player @capgo/capacitor-video-player