@capgo/capacitor-mock-location-detector

中文文档
8.0.10发布于 2026/10/15MPL-2.0TypeScriptESM + CJS零依赖构建来源已验证近 30 天下载 4.7万

Capacitor plugin for detecting simulated GPS locations and developer tooling that enables spoofing apps.

原始使用文档
文档目录25 节
  1. ➡️ Get started for free
  2. Key features
  3. Snapshot
  4. Problem & Scope
  5. Why this plugin exists
  6. What it does
  7. What it does not do
  8. Compatibility
  9. Install
  10. Setup
  11. iOS
  12. Android
  13. Usage
  14. Check layers
  15. Capgo Links
  16. getCapabilities()
  17. analyze(...)
  18. runCheck(...)
  19. openDeveloperSettings()
  20. startMonitoring(...)
  21. stopMonitoring()
  22. addListener('locationIntegrityChanged', ...)
  23. getPluginVersion()
  24. Interfaces
  25. Type Aliases

@capgo/capacitor-mock-location-detector

Detect fake GPS and location spoofing in your Capacitor app with layered, App Store safe checks on iOS and Android. Protect check-ins, deliveries and location-based rewards.

Capgo - Build Capacitor apps with AI, ship updates instantly

Capgo: push fixes to your Capacitor users in minutes, build signed iOS and Android apps without a Mac, and roll back in one click.

➡️ Get started for free

14-day unlimited free trial. No credit card required

🤖 Building with an AI coding agent? Install Capgo skills so Claude Code, Codex, Cursor, Copilot, or Gemini CLI know how to install and use @capgo/capacitor-mock-location-detector in your Capacitor app: npx skills add Cap-go/capgo-skills. Then ask your agent: "Add @capgo/capacitor-mock-location-detector to my Capacitor app and wire it up." Agent setup guides · Hosted MCP

@capgo/capacitor-mock-location-detector for Capacitor apps

Key features

  • Full analysis: analyze() returns isSimulated, a confidence level, a riskScore and the triggered checks.
  • Single checks: runCheck() for the mock flag, mock location apps, developer options, ADB, simulator, location anomalies and motion correlation.
  • Monitoring: startMonitoring() and the locationIntegrityChanged event when the verdict changes.
  • Capabilities: getCapabilities() lists the checks the platform supports.
  • Developer settings: openDeveloperSettings() on Android.
  • Platforms: iOS and Android. Not available on web.

Snapshot

  • Plugin name: @capgo/capacitor-mock-location-detector
  • One-line value: Multi-layer GPS spoofing and developer tooling detection for Capacitor apps
  • Maintainer: Capgo
  • Status: beta

Problem & Scope

Why this plugin exists

Tools like PoKeep and iMyFone AnyTo can spoof device location. A single flag such as iOS isSimulatedBySoftware is not reliable against every spoofing method. This plugin combines multiple independent signals so your app can make better fraud-prevention decisions.

What it does

  • Runs layered checks: system mock flags, developer options, known mock apps, movement heuristics, and motion correlation
  • Returns a scored LocationIntegrityResult with per-check details
  • Supports continuous monitoring with locationIntegrityChanged events
  • Opens the best-effort settings screen so users can disable developer/mock tooling themselves

What it does not do

  • Cannot programmatically disable Developer Mode or mock location settings (not allowed by iOS/Android)
  • Cannot guarantee 100% detection against every future spoofing tool
  • On iOS, Apple provides no public API to read the Developer Mode toggle directly

Compatibility

Plugin versionCapacitor compatibilityMaintained
v8.*.*v8.*.*✅
v7.*.*v7.*.*On demand
v6.*.*v6.*.*On demand

Install

npm install @capgo/capacitor-mock-location-detector
npx cap sync

Setup

iOS

Add location usage descriptions to your app Info.plist:

<key>NSLocationWhenInUseUsageDescription</key>
<string>We verify your location has not been spoofed.</string>

Optional: declare URL schemes for companion spoof apps you want to detect:

<key>LSApplicationQueriesSchemes</key>
<array>
  <string>anyto</string>
  <string>fakegps</string>
</array>

Android

Ensure your app requests runtime location permissions. The plugin declares coarse/fine location permissions in its manifest merge.

Usage

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);
}

// Guide the user, apps cannot disable developer mode automatically
await MockLocationDetector.openDeveloperSettings();

Run a single check layer:

const mockFlag = await MockLocationDetector.runCheck({
  check: 'system_mock_flag',
});

Start monitoring:

await MockLocationDetector.addListener('locationIntegrityChanged', (event) => {
  console.log('Integrity changed', event.riskScore, event.checks);
});

await MockLocationDetector.startMonitoring({ intervalMs: 30000 });

Check layers

Check IDiOSAndroidDescription
system_mock_flag✅✅OS mock/simulation flag on the current location fix
developer_options-✅Android developer options enabled
developer_mode_indicators✅✅Indirect developer/debug build heuristics
mock_location_app✅✅Known spoof app packages / URL schemes
adb_enabled-✅USB debugging enabled
mock_provider_settings-✅Apps granted mock-location permission
location_anomaly✅✅Impossible movement speed / teleport heuristic
motion_correlation✅-GPS movement without matching accelerometer activity
simulator✅✅Simulator/emulator environment
  • Plugin docs URL: https://capgo.app/docs/plugins/mock-location-detector/
  • Website/docs repo: https://github.com/Cap-go/website

Detect simulated GPS locations and developer tooling that commonly enables spoofing apps.

This plugin combines multiple independent checks because no single OS flag is reliable against tools such as PoKeep or iMyFone AnyTo. On iOS, Apple does not provide a public API to read the Developer Mode toggle directly; the plugin uses App Store-safe heuristics instead.

Apps cannot programmatically disable Developer Mode or mock location settings. Use {@link MockLocationDetectorPlugin.openDeveloperSettings} to guide users to the relevant settings.

getCapabilities()

getCapabilities() => Promise<MockLocationDetectorCapabilities>

Returns: Promise<MockLocationDetectorCapabilities>


analyze(...)

analyze(options?: AnalyzeOptions | undefined) => Promise<LocationIntegrityResult>
ParamType
optionsAnalyzeOptions

Returns: Promise<LocationIntegrityResult>


runCheck(...)

runCheck(options: RunCheckOptions) => Promise<LocationCheckResult>
ParamType
optionsRunCheckOptions

Returns: Promise<LocationCheckResult>


openDeveloperSettings()

openDeveloperSettings() => Promise<void>

startMonitoring(...)

startMonitoring(options?: MonitoringOptions | undefined) => Promise<void>

Start background integrity monitoring on native platforms.

Pair with {@link MockLocationDetectorPlugin.addListener} to receive locationIntegrityChanged events while the app is in the foreground.

ParamType
optionsMonitoringOptions

stopMonitoring()

stopMonitoring() => Promise<void>

Stop monitoring and release native location listeners.


addListener('locationIntegrityChanged', ...)

addListener(eventName: 'locationIntegrityChanged', listenerFunc: (event: LocationIntegrityChangedEvent) => void) => Promise<PluginListenerHandle>

Listen for integrity updates while {@link MockLocationDetectorPlugin.startMonitoring} is active.

ParamTypeDescription
eventName'locationIntegrityChanged'Must be 'locationIntegrityChanged'.
listenerFunc(event: LocationIntegrityChangedEvent) => void

Returns: Promise<PluginListenerHandle>


getPluginVersion()

getPluginVersion() => Promise<PluginVersionResult>

Returns: Promise<PluginVersionResult>


Interfaces

MockLocationDetectorCapabilities

PropType
platformLocationIntegrityPlatform
availableChecksLocationCheckId[]
supportsMonitoringboolean
canOpenDeveloperSettingsboolean

LocationIntegrityResult

PropType
isSimulatedboolean
confidenceLocationIntegrityConfidence
riskScorenumber
platformLocationIntegrityPlatform
checksLocationCheckResult[]
developerModeDeveloperModeResult
locationSampleLocationSample | null
recommendationstring

LocationCheckResult

PropType
idLocationCheckId
namestring
platformLocationIntegrityPlatform
availableboolean
detectedboolean
messagestring
metadata{ [key: string]: unknown; }

DeveloperModeResult

PropType
detectedboolean
canDetectDeveloperModeboolean
checksLocationCheckResult[]

LocationSample

PropType
latitudenumber
longitudenumber
accuracynumber
altitudenumber
speednumber
timestampnumber

AnalyzeOptions

PropType
checksLocationCheckId[]
requestLocationSampleboolean
locationTimeoutMsnumber
minDetectedChecksnumber
additionalMockAppPackagesstring[]
additionalMockAppUrlSchemesstring[]

RunCheckOptions

PropType
checkLocationCheckId

MonitoringOptions

PropTypeDescriptionDefault
intervalMsnumberHow often to re-run checks while monitoring is active. Minimum 5000 ms. Defaults to 30000.30000
emitOnlyOnChangebooleanWhen true, locationIntegrityChanged is emitted only when isSimulated, confidence, riskScore, or triggered check IDs change. The first event after {@link MockLocationDetectorPlugin.startMonitoring} always fires.true

PluginListenerHandle

PropType
remove() => Promise<void>

LocationIntegrityChangedEvent

Payload emitted by {@link MockLocationDetectorPlugin.addListener} when monitoring detects a new integrity snapshot.

Register the listener before calling {@link MockLocationDetectorPlugin.startMonitoring}:

PropTypeDescription
reason'interval' | 'location_update' | 'manual'Why this snapshot was emitted. - manual — first snapshot right after monitoring starts - interval — periodic re-check (intervalMs) - location_update — device location changed while monitoring (native only)

PluginVersionResult

PropType
versionstring

Type Aliases

LocationIntegrityPlatform

'ios' | 'android' | 'web'

LocationCheckId

Individual integrity checks exposed by the plugin.

'system_mock_flag' | 'developer_options' | 'developer_mode_indicators' | 'mock_location_app' | 'adb_enabled' | 'mock_provider_settings' | 'location_anomaly' | 'motion_correlation' | 'simulator'

LocationIntegrityConfidence

'none' | 'low' | 'medium' | 'high'

版本与发布记录

@capgo/capacitor-mock-location-detector 共发布 10 个版本,首次发布于 2026/06/25;过去 12 个月发布了 10 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
8.0.10latest2026/10/1525 天前
8.0.92026/10/1327 天前
8.0.82026/10/091 个月前
8.0.72026/10/081 个月前
8.0.62026/10/081 个月前
8.0.52026/09/161 个月前

关于 @capgo/capacitor-mock-location-detector 的常见问题

@capgo/capacitor-mock-location-detector 是什么?

Capacitor plugin for detecting simulated GPS locations and developer tooling that enables spoofing apps.

如何安装 @capgo/capacitor-mock-location-detector?

在项目目录运行 npm install @capgo/capacitor-mock-location-detector,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:@capacitor/core(>=8.0.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@capgo/capacitor-mock-location-detector 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@capgo/capacitor-mock-location-detector 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@capgo/capacitor-mock-location-detector 可以商用吗?

@capgo/capacitor-mock-location-detector 使用 MPL-2.0 许可。弱 Copyleft:可以商用,也可以和闭源代码一起使用;但如果分发时修改了 MPL 授权的文件,这些文件的修改需以 MPL 开源。以上为概括,不构成法律意见,请以许可原文为准。

@capgo/capacitor-mock-location-detector 的下载量有多少?

根据 npm 官方下载统计,@capgo/capacitor-mock-location-detector 在 2026/10/09 – 2026/11/07 这 30 天内被下载 47,261 次,日均约 1,575 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@capgo/capacitor-mock-location-detector 还在维护吗?

最新版本 8.0.10 发布于 2026/10/15(25 天前);至今共发布 10 个版本,其中过去 12 个月发布了 10 个;首次发布于 2026/06/25。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。