npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@dewakoding/capacitor-mock-location

v1.1.1

Published

DewaKoding Capacitor plugin to detect mock/fake GPS locations on Android devices

Downloads

359

Readme

@dewakoding/capacitor-mock-location

Capacitor plugin to detect mock or fake GPS locations on Android devices.

Overview

This plugin helps you detect when users are using fake GPS applications to spoof their location. It's useful for apps that require accurate location data, such as attendance systems, location-based services, or tracking applications.

Installation

npm install @dewakoding/capacitor-mock-location

or with yarn:

yarn add @dewakoding/capacitor-mock-location

Then sync Capacitor:

npx cap sync

Usage

import { MockLocation } from '@dewakoding/capacitor-mock-location'

const { isMock } = await MockLocation.checkMockLocation()

if (isMock) {
  console.log('Mock location detected')
  // Handle mock location case
} else {
  console.log('Location is valid')
  // Proceed with location-based operations
}

Example: Check before check-in

import { MockLocation } from '@dewakoding/capacitor-mock-location'
import { Geolocation } from '@capacitor/geolocation'

async function handleCheckIn() {
  // Check for mock location first
  const { isMock } = await MockLocation.checkMockLocation()
  
  if (isMock) {
    alert('Fake GPS detected. Please disable fake GPS apps.')
    return
  }
  
  // Get actual location
  const position = await Geolocation.getCurrentPosition()
  
  // Continue with check-in process
}

API

checkMockLocation()

Checks if the device is currently using a mock or fake GPS location.

Returns: Promise<{ isMock: boolean }>

  • isMock: true if mock location is detected, false otherwise

How It Works

The plugin uses multiple detection methods based on standard Android APIs:

  1. Checks if the current location is from a mock provider using isFromMockProvider() (Android 6.0+)
  2. Scans for providers containing "mock" or "test" keywords in LocationManager
  3. Checks if common fake GPS applications are installed on the device

Note: This implementation uses publicly available Android APIs. The code structure and implementation approach are original work by DewaKoding.

Android Setup

Permissions

Make sure your AndroidManifest.xml includes location permissions:

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />

Auto-Registration

The plugin uses @CapacitorPlugin annotation, so it will be auto-registered by Capacitor. No manual registration in MainActivity is required.

Build & Run

npm run cap:sync
npm run cap:run:android

Platform Support

  • Android: Fully supported
  • iOS: Not yet implemented (returns false)
  • Web: Not applicable (returns false)

Testing

Test with Fake GPS App

  1. Install a fake GPS app (e.g., "Fake GPS Location" from Play Store)
  2. Enable mock location in the fake GPS app
  3. Set the desired location
  4. Open your app
  5. Call checkMockLocation()
  6. Should return { isMock: true }

Test with Real Location

  1. Make sure no fake GPS apps are active
  2. Open your app
  3. Call checkMockLocation()
  4. Should return { isMock: false }

Troubleshooting

Plugin not detected

  1. Make sure you've run npx cap sync
  2. Rebuild the Android app
  3. Check logcat for errors
  4. Verify the package name in the Java file is correct

Build errors

  1. Make sure the Java file uses the correct package: com.dewakoding.capacitor.mocklocation
  2. Check if there are duplicate plugins with the same name
  3. Make sure Capacitor version is compatible (^8.0.0)

Mock location not detected

  1. Some sophisticated fake GPS apps may not be detected
  2. Make sure the fake GPS app is active and being used
  3. Try restarting the app after enabling fake GPS

Limitations

Detection is not 100% accurate. Some sophisticated fake GPS applications may not be detected. The plugin checks for common fake GPS apps, but new applications may not be in the detection list.

Development

Build the plugin:

npm run build

Watch mode:

npm run watch

License

MIT License