快速入门
复制包含安装步骤和该插件完整 Markdown 指南的配置 prompt。
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
标题为“示例:analyze”的章节import { MockLocationDetector } from '@capgo/capacitor-mock-location-detector';
const result = await MockLocationDetector.analyze();console.log(result);示例:runCheck
标题为“示例: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.ts在 GitHub 仓库中。
推荐流程
“推荐流程”章节const result = await MockLocationDetector.analyze({ requestLocationSample: true, minDetectedChecks: 1,});
if (result.isSimulated) { console.warn('Possible GPS spoofing detected', result.riskScore, result.checks);}执行单次检测
标题为“运行一次检查”的章节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();平台配置
标题为“平台配置”的章节- iOS: iOS 配置
- Android: Android 配置
单一事实来源
标题为“单一事实来源”的部分本页遵循该插件的 src/definitions.ts。当公开的 API 发生变化时,请在上游重新运行 docgen。