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.58k stars 425 forks source link

how to fetch location with specific interval #2051

Open keerthanaMol opened 3 weeks ago

keerthanaMol commented 3 weeks ago

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

christocracy commented 3 weeks ago

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

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

keerthanaMol commented 3 weeks ago

@christocracy thanks for your quick response.

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

please help me

christocracy commented 3 weeks ago

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

keerthanaMol commented 3 weeks ago

@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

christocracy commented 3 weeks ago

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.

FazilMuhammed commented 3 hours ago

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

christocracy commented 1 hour ago

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),

FazilMuhammed commented 54 minutes ago

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