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