Please provide the following:
- SDK Version: 37
- Platforms(Android/iOS/web/all): Android
hello Expo forum, I would like to ask, is there a way to keep apps inform current user location even user not moving, I try to record user location in couple of minutes, it’s working with Location.startLocationUpdatesAsync (see code below) but if user not move for long time for example while user sitting, it’s not update location, how I record user position although he is not moving
useEffect(() => {
async function startWatching() {
locationService.subscribe(onLocationUpdate)
try {
const { granted } = await Location.requestPermissionsAsync();
if (!granted) {
throw new Error('Location permission not granted');
}
let isRegistered = await TaskManager.isTaskRegisteredAsync('firstTask');
if (isRegistered) {
TaskManager.unregisterTaskAsync('firstTask')
}
await Location.startLocationUpdatesAsync('firstTask', {
accuracy: Location.Accuracy.BestForNavigation,
timeInterval: 10000,
activityType: Location.ActivityType.AutomotiveNavigation,
deferredUpdatesInterval: 15000
});
} catch (e) {
setErr(e);
}
};
startWatching()
}, []);
TaskManager.defineTask('firstTask', ({ data, error }) => {
if (error) {
// Error occurred - check `error.message` for more details.
return;
}
if (data) {
const { latitude, longitude } = data.locations[0].coords
locationService.setLocation({latitude, longitude})
// console.log('locations', locations);
}
});