Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
lane4-wiz opened this issue Oct 21, 2024 · 6 comments
Open

Comments

@lane4-wiz
Copy link

Your Environment

  • Plugin version: 4.17.1
  • Platform: Android
  • OS version: 10
  • Device manufacturer / model:
  • React Native version (react-native -v): 0.72.6
  • Plugin config
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

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

Steps to Reproduce

Context

Debug logs

Logs
PASTE_YOUR_LOGS_HERE
@lane4-wiz
Copy link
Author

Does heartbeat accuracy increase when the scheduleUseAlarmManager option is specified?

@lane4-wiz
Copy link
Author

@christocracy Please check.

@christocracy
Copy link
Member

Does heartbeat accuracy increase when the scheduleUseAlarmManager option is specified?

No

@lane4-wiz
Copy link
Author

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

@christocracy
Copy link
Member

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
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants