Skip to content

Expose Android mock-location flag in Location result #73

Description

@alemar11

Problem

For fraud-sensitive flows such as attendance, timecard, delivery check-ins, or field-service check-ins, Android mock locations are important metadata. Android can mark a Location as coming from a mock provider, but react-native-get-location currently does not expose that flag to JavaScript.

The current Android mapper returns fields such as provider, latitude, longitude, accuracy, altitude, speed, bearing, and time:

That means an app receives only coordinates and related metadata, with no way to distinguish a location that Android has already marked as mock.

Requested behavior

Expose a boolean field on Android location results, for example:

type Location = {
  latitude: number;
  longitude: number;
  // ...existing fields
  mocked?: boolean; // Android only
}

The Android implementation could populate it from the same native Location object before resolving the promise.

Recommended compatibility approach:

  • Use Location.isMock() on Android 12 / API 31+.
  • Use Location.isFromMockProvider() on older Android versions.
  • Or use AndroidX LocationCompat.isMock(location) as the compatibility helper.

References

Security note

This would not prove that a location is physically real. A rooted or instrumented device may still bypass client-side checks. But exposing Android's native mock-location flag would let apps make informed decisions, block obvious mock-provider locations, send risk metadata to the backend, or route suspicious events for review.

Why this belongs in the library

The flag must be read from the same native Location object used for the coordinates. If apps need to call a separate mock-location detector after receiving coordinates, they can introduce time-of-check/time-of-use inconsistencies where the detector and the submitted coordinates do not refer to the same fix.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions