スタートガイド
インストール手順と、このプラグインの完全なMarkdownガイドを含むセットアッププロンプトをコピーします。
Set up this Capacitor plugin in the project.
Use the package manager already used by the project.
Install these package(s): `@capgo/capacitor-mock-location-detector`
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/mock-location-detector/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-mock-location-detectorbunx cap syncインポート
「インポート」セクションimport { MockLocationDetector } from '@capgo/capacitor-mock-location-detector';クイックスタート
「クイックスタート」セクションimport { MockLocationDetector } from '@capgo/capacitor-mock-location-detector';
const result = await MockLocationDetector.getCapabilities();console.log(result);例: analyze
セクション「Example: analyze」import { MockLocationDetector } from '@capgo/capacitor-mock-location-detector';
const result = await MockLocationDetector.analyze();console.log(result);例: runCheck
セクション「Example: runCheck」import { MockLocationDetector } from '@capgo/capacitor-mock-location-detector';
const result = await MockLocationDetector.runCheck({ check: 'system_mock_flag' });console.log(result);よくある落とし穴
「よくある落とし穴」セクション- リスナー: 画面がアンマウントされたらハンドルを削除します。
- ネイティブ同期: 実行
bunx cap syncプラグインのアップグレード後。 - 信頼できる情報源: 信頼
src/definitions.tsGitHub リポジトリ内。
推奨フロー
セクション「推奨フロー」const result = await MockLocationDetector.analyze({ requestLocationSample: true, minDetectedChecks: 1,});
if (result.isSimulated) { console.warn('Possible GPS spoofing detected', result.riskScore, result.checks);}単発のチェックを実行
「チェックを1回実行」セクションconst mockFlag = await MockLocationDetector.runCheck({ check: 'system_mock_flag',});継続的に監視
「継続的に監視」セクションawait MockLocationDetector.addListener('locationIntegrityChanged', (event) => { console.log('Integrity changed', event.confidence, event.checks);});
await MockLocationDetector.startMonitoring({ intervalMs: 30000 });ユーザーを設定画面へ誘導
「ユーザーを設定画面へ誘導」セクションアプリから開発者モードやモックロケーションを自動で無効化することはできません。代わりに設定画面を開いてください:
await MockLocationDetector.openDeveloperSettings();プラットフォームのセットアップ
「Platform Setup」セクション- iOS: iOSの設定
- Android: Androidの設定
Source of Truth
「Source Of Truth」セクションこのページはプラグインの src/definitions.tsに従います。パブリックの API が変更された場合は、アップストリームで docgen を再実行してください。