指南
模拟位置检测器教程
使用@capgo/capacitor-mock-location-detector
使用层次化、App Store安全的iOS和Android检查模拟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/