react-native-geolocation icon indicating copy to clipboard operation
react-native-geolocation copied to clipboard

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

Open Saim-Ramzan opened this issue 8 months ago • 6 comments

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

Saim-Ramzan avatar Mar 07 '25 06:03 Saim-Ramzan