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

Watch position not working on huawei cloud device

Open shilohchis opened this issue 4 years ago • 7 comments

Hi there, thanks for provide this awesome lib I have issue with watchPosition doesn't work when test on huawei cloud device It doesn't trigger the watchPosition, put the console log inside success & error callback not even call the console.log The lib mentioned it use google play service FusedLocationProviderClient API, is it not support for android without google play service?? image

shilohchis avatar Nov 23 '21 08:11 shilohchis

Set forceLocationManager: true to use the default android location api

Agontuk avatar Nov 24 '21 15:11 Agontuk

Still not working with forceLocationManager: true

shilohchis avatar Nov 24 '21 15:11 shilohchis

Does getCurrentPosition work or times out ? Also please provide a code sample.

Agontuk avatar Nov 24 '21 16:11 Agontuk

getCurrentPosition works the sample code is like

  const geolocationOptions = {
    enableHighAccuracy: false, //try with true, not working
    forceLocationManager: true, //try with false, not working
    distanceFilter: 0,
    interval: 100,
    fastestInterval: 10,
    showLocationDialog: true,
  }
  const locWatchIdRef = useRef<number | null>(null)

  useEffect(() => {
    startWatchingLocation()
    return stopWatchingLocation
  }, [])

  const stopWatchingLocation = () => {
    if (locWatchIdRef.current !== null) {
      Geolocation.clearWatch(locWatchIdRef.current)
      locWatchIdRef.current = null
    }
  }

  const startWatchingLocation = () => {
    locWatchIdRef.current = Geolocation.watchPosition(
      (position) => {
        // we do some calculation here
      },
      () => {
        stopWatchingLocation()
      },
      geolocationOptions,
    )
  }

shilohchis avatar Dec 01 '21 16:12 shilohchis

Try the example project and see if the same issue happens. Code looks fine to me.

Agontuk avatar Dec 05 '21 05:12 Agontuk

Its not working here either with React 0.67.3 and a Motorola Moto G 9 Plus. All permissions granted, but the watcher callback is only called once.

With or without: forceLocationManager true/false or useSignificantChanges true/false

EduFrazao avatar Apr 05 '22 22:04 EduFrazao

Its not working here either with React 0.67.3 and a Motorola Moto G 9 Plus. All permissions granted, but the watcher callback is only called once.

With or without: forceLocationManager true/false or useSignificantChanges true/false

I'm also facing same issue with watchPosition

liptonzuma avatar Jul 22 '22 19:07 liptonzuma