react-native-background-geolocation icon indicating copy to clipboard operation
react-native-background-geolocation copied to clipboard

how to fetch location with specific interval

Open keerthanaMol opened this issue 1 year ago • 11 comments

i have pizza delivery application when order taken i need to start process each 5 minute interval i need get location is it possible with this library ?

my react native version 0.72.5 react-native-background-geolocation 4.16.2 react-native-background-fetch 4.2.5

what are parameters i need give inside BackgroundGeolocation.ready

keerthanaMol avatar Jun 12 '24 13:06 keerthanaMol

iOS is strictly distance-based. For Android, see Config.locationUpdateInterval.

you don’t save any battery with an update interval of 10s vs 5min.

christocracy avatar Jun 12 '24 13:06 christocracy

@christocracy thanks for your quick response.

finaly how confiq look like i need get my current location with specifc interval

please help me

keerthanaMol avatar Jun 12 '24 13:06 keerthanaMol

I suggest you just use distanceFilter with a reasonable value, such as 100 or 200 meters.

You don’t need time-based updates.

read the api docs Config.distanceFilter

christocracy avatar Jun 12 '24 13:06 christocracy

@christocracy actual my requirement is for office purpose not for pizza delivery. some employee requested for work from home option we recored there location then hr will understand employe is working properly any support from you

keerthanaMol avatar Jun 12 '24 13:06 keerthanaMol

Read the wiki “Philosophy of Operation”.

when the device moves about 200 meters from the last known location, the plug-in will begin tracking and you will know. Otherwise, the device is at the last known location. I suggest you see the api docs Config.useSignificantChangesOnly, as well.

also research sending server push requests to a device. In your push request callback, you are free to interact with the plug-in to call .getCurrentPosition.

you could also implement background-fetch (already included as a dependency; see its readme) to call .getCurrentPosition.

christocracy avatar Jun 12 '24 14:06 christocracy

there is important issue

some time our employe will disable gps or location then I think fetching location is will stop then company will understand employee is working from their given location or sometime they migrating from some location.thats why I am asking is possible get location with 15 min interval

please help @christocracy I am in trouble

FazilMuhammed avatar Jul 09 '24 05:07 FazilMuhammed

The user has full control to hide from you if they wish.

listen to event .onProviderChange to learn when device location is disabled.

use background-fetch (already included as a dependency; read its readme) to implement a periodic callback which you can use to execute .getCurrentPosition),

christocracy avatar Jul 09 '24 07:07 christocracy

thank you for your replay @christocracy is there I need declare this code in use effect

useEffect(() => { BackgroundGeolocation.ready({ // Geolocation Config desiredAccuracy: BackgroundGeolocation.DESIRED_ACCURACY_HIGH, disableElasticity: false, elasticityMultiplier: 2, showsBackgroundLocationIndicator: true, preventSuspend: true, heartbeatInterval: 30, // Activity Recognition stopTimeout: 5, locationAuthorizationRequest: 'always', foregroundService: true, notification: { title: 'Wandeling aan het opnemen', text: 'App neemt je wandeling op', priority: BackgroundGeolocation.NOTIFICATION_PRIORITY_HIGH, channelName: 'WalkingApp', }, backgroundPermissionRationale: { title: "Allow {applicationName} to access this device's location even when closed or not in use.", message: 'This app collects location data to enable recording your trips to work and calculate distance-travelled.', positiveAction: 'Change to "{backgroundPermissionOptionLabel}"', negativeAction: 'Cancel', }, enableHeadless: true, // Application config debug: false, // <-- enable this hear sounds for background-geolocation life-cycle. logLevel: BackgroundGeolocation.LOG_LEVEL_VERBOSE, stopOnTerminate: false, // <-- Allow the background-service to continue tracking when user closes the app. startOnBoot: true, // <-- Auto start tracking when device is powered-up. }).then(state => { console.log(state, 'state'); console.log( '- BackgroundGeolocation is configured and ready: ', state.enabled, ); }); }, []);

when I console BackgroundGeolocation is configured and ready: getting false how to enable this true and one more doubt also I have BackgroundGeolocation.getCurrentPosition(options); what are parameters I need to give inside option

please help

FazilMuhammed avatar Jul 09 '24 08:07 FazilMuhammed

This issue is stale because it has been open for 30 days with no activity.

github-actions[bot] avatar Aug 09 '24 01:08 github-actions[bot]

@christocracy If device is not moving then send the location to configured url after specific interval of time. Is this possible?

I tried with locationUpdateInterval for android but it's not send location after specific interval of time when device is not moving.

haiderTkxel avatar Aug 15 '24 14:08 haiderTkxel

The plug-in does not record location while in the stationary state.

use background-fetch, already included as a dependency, to execute periodic callbacks. See its readme. Call .getCurrentPosition in your fetch callback.

christocracy avatar Aug 15 '24 15:08 christocracy

This issue is stale because it has been open for 30 days with no activity.

github-actions[bot] avatar Sep 15 '24 02:09 github-actions[bot]

This issue was closed because it has been inactive for 14 days since being marked as stale.

github-actions[bot] avatar Sep 29 '24 02:09 github-actions[bot]