Skip to content

Issue is Current Location if pass the enableHighAccuracy Flase then some device is worked and enableHighAccuracy True then some device is not worked #355

@Saim-Ramzan

Description

@Saim-Ramzan

Environment

Platforms

Versions

  • Android:
  • iOS:
  • react-native-geolocation:
  • react-native:
  • react:

Description

I am using this type of code
useEffect(() => {
let locationTimeout: NodeJS.Timeout | null = null

locationTimeout = setTimeout(() => {
  if (!userLocation) {
    showMessage("Please turn on your GPS.", "error", "Location required")
  }
}, 5000)

Geolocation.getCurrentPosition(
  (position) => {
    setUserLocation(position.coords)
    if (locationTimeout) clearTimeout(locationTimeout)
  },
  (error) => {
    console.info("[getUserLocation] ERROR - ", error)
    showMessage(
      "Please check your permissions and your GPS connection.",
      "error",
      "Couldn't retrieve your location",
    )
    setUserLocation(null)
    if (locationTimeout) clearTimeout(locationTimeout)
  },
  { enableHighAccuracy: false, timeout: 20000, maximumAge: 20000 },
)

return () => {
  if (locationTimeout) clearTimeout(locationTimeout)
}

}, [])

Reproducible Demo

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions