# react-native-turbo-mock-location-detector

> Package helps to detect mocked location on both Android and iOS

Latest version **2.3.1** (published 2023-10-12) · MIT license · 0 weekly downloads

## Install

```sh
npm install react-native-turbo-mock-location-detector
pnpm add react-native-turbo-mock-location-detector
yarn add react-native-turbo-mock-location-detector
bun add react-native-turbo-mock-location-detector
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.3.1 |
| Published | 2023-10-12 |
| First published | 2022-08-26 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 82.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 112 |
| Author | Jacek Pudysz |
| Maintainers | jpudysz |
| Keywords | react-native, ios, android |

## Links

- npm: https://www.npmjs.com/package/react-native-turbo-mock-location-detector
- Repository: https://github.com/jpudysz/react-native-turbo-mock-location-detector
- Homepage: https://github.com/jpudysz/react-native-turbo-mock-location-detector#readme
- Issues: https://github.com/jpudysz/react-native-turbo-mock-location-detector/issues
- npm.io page: https://npm.io/package/react-native-turbo-mock-location-detector

## Alternatives

- [@sindresorhus/slugify](https://npm.io/package/@sindresorhus/slugify.md) — 3.7M weekly downloads
- [solid-js](https://npm.io/package/solid-js.md) — 2.7M weekly downloads
- [expo-glass-effect](https://npm.io/package/expo-glass-effect.md) — 2.5M weekly downloads
- [nanoassert](https://npm.io/package/nanoassert.md) — 780.8K weekly downloads
- [@ffmpeg/ffmpeg](https://npm.io/package/@ffmpeg/ffmpeg.md) — 529.5K weekly downloads

## Recent versions

- 2.3.1 (latest) — 2023-10-12
- 2.3.0 — 2023-07-01
- 2.2.0 — 2023-07-01
- 2.0.1 — 2023-03-28
- 2.0.0 — 2023-01-26
- 1.2.0 — 2022-09-12
- 1.1.2 — 2022-09-08
- 1.1.1 — 2022-08-29
- 1.1.0 — 2022-08-29
- 1.0.0 — 2022-08-26

## README

# react-native-turbo-mock-location-detector

Protect your business from location spoofing. Mock location detector is designed to detect and prevent any attempts to spoof GPS location, making it the perfect solution for any use case that requires accurate location tracking. Common examples include fleet management and logistics apps where truck drivers may use tools like [Location Changer](https://www.ultfone.com/ios-location-changer.html) and [Mock Locations](https://play.google.com/store/apps/details?id=ru.gavrikov.mocklocations&hl=pl&gl=US).

Library supports both new and old architecture of React Native.

## Installation

```sh
yarn add react-native-turbo-mock-location-detector
cd ios && pod install
```

## Expo
Works with no additional config

## Prerequisites

1. Use eg. [react-native-permissions](https://github.com/zoontek/react-native-permissions) to ask for location permission
2. In your AndroidManifest.xml use at least one of:
```xml
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
```
3. In your Info.plist use:
```text
<key>NSLocationWhenInUseUsageDescription</key>
<string>YOUR TEXT</string>
```

## Usage

```typescript
import { isMockingLocation, MockLocationDetectorErrorCode, MockLocationDetectorError } from 'react-native-mock-location-detector'

useEffect(() => {
    isMockingLocation()
        .then(({ isLocationMocked }) => {
            // isLocationMocked: boolean
            // boolean result for Android and iOS >= 15.0
        })
        .catch((error: MockLocationDetectorError) => {
            // error.message - descriptive message
            switch (error.code) {
                case MockLocationDetectorErrorCode.GPSNotEnabled: {
                    // user disabled GPS
                    return
                }
                case MockLocationDetectorErrorCode.NoLocationPermissionEnabled: {
                    // user has no permission to access location
                    return
                }
                case MockLocationDetectorErrorCode.CantDetermine: {
                    // always for iOS < 15.0
                    // for android and iOS if couldn't fetch GPS position
                }
            }
        })
}, [])

```

## Support

| Lib version | RN version |
|-------------|------------|
| 1.0 - 1.2   | \>= 0.68   |
| ^2.0        | 0.71, 0.72 |


## Testing
Library was tested:
- on iOS with the use of [Location Changer](https://www.ultfone.com/ios-location-changer.html)
- on Android with the use of [Mock Locations](https://play.google.com/store/apps/details?id=ru.gavrikov.mocklocations&hl=pl&gl=US)


## Contributing

See the [contributing guide](CONTRIBUTING.md) to learn how to contribute to the repository and the development workflow.

## License

MIT

---

---
_Source: https://npm.io/package/react-native-turbo-mock-location-detector · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
