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

capacitor-location-plugin

v1.2.6

Published

Capacitor plugin to check if location is enabled

Readme

Capacitor Location Plugin

A Capacitor plugin to check whether location services are enabled, listen for changes in real time, and detect fake / mock GPS (spoofing apps such as Lockito, Fake GPS, etc.).

Features

  • Check if location services are enabled (isEnabled)
  • Listen for location-services changes (locationStatusChanged event)
  • Detect mock / spoofed location (checkMock) — on Android reads the mock flag from the fused provider (the source most apps use); on iOS 15+ reads CLLocation.sourceInformation.isSimulatedBySoftware. Catches a spoofed position even while the device is stationary
  • Open the device settings so the user can disable the mock-location app (openDeveloperSettings)
  • Lightweight: the status check uses system broadcasts (no continuous updates)

Mock detection support: Android, and iOS 15+. On iOS below 15 and on web, checkMock resolves { isMock: false, available: false }.


Installation

npm install capacitor-location-plugin
npx cap sync

The mock detection uses com.google.android.gms:play-services-location, which the plugin declares as a dependency — no extra setup required.


Usage

import { LocationPlugin } from 'capacitor-location-plugin';

Check if location services are enabled

const { isEnabled } = await LocationPlugin.isEnabled();

Listen for location-services changes

const listener = await LocationPlugin.addListener(
  'locationStatusChanged',
  (status) => {
    console.log('Location enabled:', status.isEnabled);
  },
);

// later
listener.remove();

Detect fake / mock GPS

const { isMock, available } = await LocationPlugin.checkMock();

if (available && isMock) {
  // A mock-location app is actively feeding the position.
  await LocationPlugin.openDeveloperSettings();
}

Poll it on an interval (and re-check on app resume) to react when the user enables or disables a spoofing app:

setInterval(async () => {
  const { isMock, available } = await LocationPlugin.checkMock();
  if (available) blocked.value = isMock;
}, 5000);

API

isEnabled()

isEnabled() => Promise<{ isEnabled: boolean }>

Returns whether GPS/network location services are enabled.

initialize(options?)

initialize(options?: any) => Promise<{ isEnabled: boolean }>

Registers the internal broadcast receiver and returns the current status. Call once before relying on locationStatusChanged.

checkMock()

checkMock() => Promise<{ isMock: boolean; available: boolean }>

Requests a fresh location and reports whether it is mocked.

  • Android: reads the fused provider (Location.isMock() on API 31+, isFromMockProvider() below), falling back to the LocationManager providers if fused is unavailable.
  • iOS 15+: requests a one-shot location and reads CLLocation.sourceInformation.isSimulatedBySoftware.

Fields:

  • isMock: true when the current position comes from a mock/simulated source.
  • available: false when the check could not run (no location permission, iOS below 15, or web) — treat isMock as inconclusive.

Requires location permission granted at runtime (ACCESS_FINE_LOCATION/ACCESS_COARSE_LOCATION on Android, when-in-use on iOS).

openDeveloperSettings()

openDeveloperSettings() => Promise<void>

On Android, opens the developer settings screen (falls back to the main settings) so the user can turn off the selected mock-location app. On iOS, opens the app's settings page.

addListener('locationStatusChanged', ...)

addListener(
  eventName: 'locationStatusChanged',
  listenerFunc: (status: { isEnabled: boolean }) => void,
) => Promise<PluginListenerHandle>

Android setup

Add the location permissions to your app's AndroidManifest.xml:

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

iOS setup

In Info.plist, add usage descriptions:

<key>NSLocationWhenInUseUsageDescription</key>
<string>This app requires access to your location while using the app.</string>

Limitations

Mock detection relies on the OS simulated-location flag. It reliably catches spoofing apps on a non-rooted / non-jailbroken device. A rooted Android device running a mock-hiding module (Xposed/LSPosed) can suppress the flag; defeating that requires attestation (e.g. Play Integrity) and is out of scope for this plugin. iOS detection requires iOS 15+ (no public API exists below that).


License

MIT