transistorsoft / react-native-background-geolocation

Sophisticated, battery-conscious background-geolocation with motion-detection
http://shop.transistorsoft.com/pages/react-native-background-geolocation
MIT License
2.65k stars 425 forks source link

I would like to receive location information periodically (1 minute). #2181

Open lane4-wiz opened 2 weeks ago

lane4-wiz commented 2 weeks ago

Your Environment

heartbeatInterval: 60,

BackgroundGeolocation.onHeartbeat(event => { console.log('[onHeartbeat] ', dayjs().format('YYYY-MM-DD HH:mm:ss'), event); BackgroundGeolocation.getCurrentPosition({ timeout: 30, maximumAge: 5000, samples: 1, }).then(location => { console.log('[getCurrentPosition] ', location); }); }),


## Expected Behavior
<!--- Tell us what should happen -->

It was implemented to receive location information every minute using heartbeat, but there are many cases where location information cannot be received within 1 minute.

Is there a way to receive location information with less error every minute?

## Actual Behavior
<!--- Tell us what happens instead -->

## Steps to Reproduce
<!--- reproduce this issue; include code to reproduce, if relevant -->
1.
2.
3.
4.

## Context
<!--- What were you trying to do? -->

## Debug logs
<!-- include iOS / Android logs
- ios XCode logs,
- use #getLog #emailLog methods (@see docs)
- Android: $ adb logcat -s TSLocationManager
-->
<details><summary>Logs</summary>

``` <!-- Syntax highlighting:  DO NOT REMOVE -->
PASTE_YOUR_LOGS_HERE

lane4-wiz commented 2 weeks ago

Does heartbeat accuracy increase when the scheduleUseAlarmManager option is specified?

lane4-wiz commented 1 week ago

@christocracy Please check.

christocracy commented 1 week ago

Does heartbeat accuracy increase when the scheduleUseAlarmManager option is specified?

No

lane4-wiz commented 1 week ago

@christocracy So, is there a way to periodically receive location information?

christocracy commented 1 week ago

is there a way to periodically receive location information?

Yes, that's what react-native-background-fetch is for (already included as a dependency). See its README.

In your BackgroundFetch callback function, you're free to do anything you want, including BackgroundGeolocaiton.getCurrentPosition(options).

christocracy commented 1 week ago

You'll never get a location "every minutes" while the device is stationary.

Deepanshi09 commented 6 days ago

@christocracy but is it possible - Location updates occur every two minutes?

christocracy commented 6 days ago

While stationary, the best you’ll get is every 15 minutes, using background-fetch