指南
如何在 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/