指南
如何在 Capacitor 中使用 Mock Location Detector
使用 @capgo/capacitor-mock-location-detector
通过 iOS 和 Android 上多层且符合 App Store 安全规范的检测,识别模拟的 GPS 位置。
安装
bun add @capgo/capacitor-mock-location-detector
bunx cap sync
插件暴露的内容
analyze- 运行所有可用检查并返回评分后的综合结果。runCheck- 执行指定的检测层。getCapabilities- 发现当前平台支持的检查项。startMonitoring/stopMonitoring- 通过事件进行定期分析。openDeveloperSettings- 引导用户禁用开发者工具或模拟工具。
用法示例
import { MockLocationDetector } from '@capgo/capacitor-mock-location-detector';
const result = await MockLocationDetector.analyze({
requestLocationSample: true,
minDetectedChecks: 1,
});
if (result.isSimulated) {
console.warn('Possible GPS spoofing detected', result.checks);
}
await MockLocationDetector.openDeveloperSettings();
完整参考
- GitHub: https://github.com/Cap-go/capacitor-mock-location-detector/
- 文档: /docs/plugins/mock-location-detector/