Agontuk / react-native-geolocation-service

React native geolocation service for iOS and android
https://www.npmjs.com/package/react-native-geolocation-service
MIT License
1.6k stars 291 forks source link

Watch position not working on huawei cloud device #321

Open shilohchis opened 2 years ago

shilohchis commented 2 years ago

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

Agontuk commented 2 years ago

Set forceLocationManager: true to use the default android location api

shilohchis commented 2 years ago

Still not working with forceLocationManager: true

Agontuk commented 2 years ago

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

shilohchis commented 2 years ago

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,
    )
  }
Agontuk commented 2 years ago

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

EduFrazao commented 2 years ago

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

liptonzuma commented 2 years ago

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