はじめに
このプラグインのインストール手順と全マークダウンガイドを含む設定プロンプトをコピーします。
Set up this Capacitor plugin in the project.
Use the package manager already used by the project.
Install these package(s): `@capgo/capacitor-webview-version-checker`
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-version-checker/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.
-
パッケージをインストール
ターミナル画面 bun add @capgo/capacitor-webview-version-checker -
ネイティブプロジェクトを同期
ターミナル画面 bunx cap sync -
オプション: プラグイン設定を追加 デフォルトで実行できます (
WebviewVersionChecker: {}) または、プロンプトと閾値の動作をカスタマイズできます。capacitor.config.ts.
デフォルトの動作 (主な使用例)
デフォルトの動作 (主な使用例) のセクションデフォルトでは、このプラグインはブラウザリストスタイルの互換性規則を使用します。
minimumDeviceSharePercentデフォルトでは3- シェア データセットは、ビルド時に caniuse データからバンドルされます。
- デフォルトのフローでは、ランタイム データセット URL の呼び出しは必要ありません。
import type { CapacitorConfig } from '@capacitor/cli';
const config: CapacitorConfig = { plugins: { WebviewVersionChecker: {}, },};
export default config;シンプルな設定のみのセットアップ (ネイティブのプロンプトを表示)
シンプルな設定のみのセットアップ (ネイティブのプロンプトを表示) のセクションimport type { CapacitorConfig } from '@capacitor/cli';
const config: CapacitorConfig = { plugins: { WebviewVersionChecker: { autoPromptOnOutdated: true, }, },};
export default config;高度な閾値モード (カスタム データセット)
高度な閾値モード (カスタム データセット) のセクションimport type { CapacitorConfig } from '@capacitor/cli';
const config: CapacitorConfig = { plugins: { WebviewVersionChecker: { minimumDeviceSharePercent: 3, versionShareByMajor: { '137': 58.2, '136': 21.3, '135': 4.6, '134': 2.1, }, autoPromptOnOutdated: true, }, },};
export default config;実際のシェアに基づく互換性のみではなく、固定バージョンにのみ基づく場合にのみ使用してください。
minimumDeviceSharePercent: 3__CAPGO_KEEP_0__のインストールされたメジャーバージョンは、データセット内の3%以上を表す必要があります。versionShareByMajor__CAPGO_KEEP_0__は、メジャーバージョン => パーセンテージというカスタムマップをサポートしています。- リモートデータを使用する場合は、
versionShareApiUrlのいずれかを使用してください。{ "versionShareByMajor": { "137": 54.2, "136": 23.8 } }{ "shareByMajor": { "137": 54.2, "136": 23.8 } }{ "versions": [{ "major": 137, "share": 54.2 }, { "version": "136.0.0.0", "percent": 23.8 }] }
高度な使用法(JavaScript)
「高度な使用法(JavaScript)」というセクションimport { WebviewVersionChecker } from '@capgo/capacitor-webview-version-checker';
await WebviewVersionChecker.addListener('webViewOutdated', (status) => { console.log('Outdated WebView detected', status);});
await WebviewVersionChecker.check({ minimumMajorVersion: 124, showPromptOnOutdated: true,});Capacitorの代わりにこのプラグインを使用する理由
「Capacitorの代わりにこのプラグインを使用する理由」というセクションCapacitorは静的最小値チェックをサポートしています。
android: { minWebViewVersion: 124,},server: { errorPath: 'unsupported-webview.html',}このプラグインは、実行時イベントとネイティブのプロンプトUIを追加するため、ユーザーはアプリを更新するように誘導されながらも、アプリを開いて使用できます。
評価順序:
- デバイスシェアリング閾値モード(+データセット)が指定されている場合
minimumDeviceSharePercent最新バージョンモード( - 最小主バージョンフォールバック(
latestVersion/latestVersionApiUrl) - Android プロバイダハンドリング
minimumMajorVersion)
セクション「Android プロバイダハンドリング」
__CAPGO_KEEP_0__ が Android 上で使用する WebView プロバイダーモデルを両方サポートしています。The plugin supports both WebView provider models used by Capacitor on Android:
- Android 7-9: Google Chrome (
com.google.android.webview) - Android 7-9: Google Chrome (
com.android.chrome)