'expo-location startLocationUpdatesAsync triggered too rarely

This is where i trigger Location.startLocationUpdatesAsync

useEffect(() => {
    if (isPermissionReady && destination && !intervalHandle.current) {
      // Register location fetch to task manager
      Location.startLocationUpdatesAsync(TASK_NAME, {
        accuracy: Location.Accuracy.Balanced,
        // activityType: Location.ActivityType.AutomotiveNavigation,
        // deferredUpdatesTimeout: INTERVAL_MS,
      })
      // Repeatedly read local storage to update currentPos state
      intervalHandle.current = setInterval(updateCurrentPos, INTERVAL_MS)
    }
  }, [isPermissionReady, destination])

And this is my TaskManager (declared separately in index.tsx not inside a lifecycle or hook):

TaskManager.defineTask(TASK_NAME, ({ data, error }) => {
  if (error) {
    console.error('Task Manager Failed')
    return
  }
  if (data) {
    const { locations } = (data as any) ?? { locations: [] }
    const { latitude, longitude } = locations[0]?.coords ?? {}
    try {
      AsyncStorage.setItem(STORAGE_KEY, JSON.stringify({ latitude, longitude }))
    } catch {
      console.error('SetItem Failed')
    }
  }
})

My taskmanager reads location data from device and save to LocalStorage(AsyncStorage) and react native app fetches this data with setInterval. However, data set by TaskManager is updated too rarely and it is not called regularly in constant time(imo) and never called if I stay at the same place with all deferredOOO options disabled.

Does startLocationUpdatesAsync trigger only after some distance change even with default values? or am I doing something wrong? (I want it to be called in regular basis or at least have a clear understanding of when it is called)

Plus, is it normal for taskmanager to not show any console.log?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source