react-native-background-geolocation
react-native-background-geolocation copied to clipboard
Getting issue in setting the interval for location update in database
Your Environment
"react-native-background-fetch": "^4.1.10", "react-native-background-geolocation": "^4.12.1",
- Platform: Android
- OS version: 12
- Device manufacturer and model: OPPO CPH2095
- React Native version: 0.64
- Plugin config
const state:State = await BackgroundGeolocation.ready({
url:"https://hkdk.events/9JXddKxb5fnn",
reset: false,
debug: true,
locationTemplate: '{"Latitude":<%= latitude %>,"Longitude":<%= longitude %>,"TimeStamp": "<%= timestamp %>"}',
autoSync:true,
deferTime:180000,
params: {
ClientId:respo_storage.data.ClientId,
},
headers: {
authorization: "Bearer "+getToken.data.Token,
source:source
},
logLevel: BackgroundGeolocation.LOG_LEVEL_VERBOSE,
desiredAccuracy: BackgroundGeolocation.DESIRED_ACCURACY_HIGH,
distanceFilter: 0,
locationUpdateInterval:180000,
allowIdenticalLocations:false,
stopTimeout: 5,
fastestLocationUpdateInterval:180000,
locationAuthorizationRequest: 'Always',
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'
},
maxDaysToPersist: 14,
stopOnTerminate: false,
startOnBoot: true,
enableHeadless: true,
});
## Expected Behavior
Location must be updated in db exactly after 3 min even in still mode or moving ## Actual Behavior
Actual Behaviour
Location is updating most after 3 min but in rare cases it updates after 2 min , and multiple locations at same time## Steps to
This issue is not resolved yet
reset: false,
Do you know what this does? Why do you set it to false?
This was set to false in Demo Application provided in the library , I didn't get the meaning of it What exactly it is doing
Delete that whole line from your Config reset: false.
ok
Tried deleting this but Still getting issue with the Accuracy If I use locationUpdateInterval instead of distance filter , Its our requirement that we need to update location after specific interval also getting issue with still mode , latitude and longitude are not accurate in still mode const state: State = await BackgroundGeolocation.ready({
url: "http://92.204.135.120:8099/TomAPI/SaveLocationInformation",
debug: true,
logLevel: BackgroundGeolocation.LOG_LEVEL_VERBOSE,
desiredAccuracy: BackgroundGeolocation.DESIRED_ACCURACY_NAVIGATION,
distanceFilter: 0,
locationUpdateInterval: interval,
stopTimeout: 5,
locationTemplate: '{"Latitude":<%= latitude %>,"Longitude":<%= longitude %>,"TimeStamp": "<%= timestamp %>"}',
locationAuthorizationRequest: 'Always',
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'
},
headers: {
authorization: "Bearer " + getToken.data.Token,
source: source
},
params: {
ClientId: respo_storage.data.ClientId,
},
batchSync: true,
autoSync: true,
maxDaysToPersist: 14,
stopOnTerminate: false,
startOnBoot: true,
enableHeadless: true
});
latitude and longitude are not accurate in still mode
What makes you suspect that they’re “not accurate”?
I am showing the lat long on map and it is showing in slightly different position from where I was actually situated
And why are you not showing me this map?
ok I will share the map screenshot also
Do you know that the geolocation accuracy while indoors is 40-60 meters? GPS only works outdoors (accuracy ~5 meters).
Do you know that a geolocation is not a simple point in space? It’s a circle of probability with radius location.coords.accuracy meters. The real location of the device is somewhere in that circle.
I suggest you go outside for a nice long test of >1km.
@christocracy We are facing this issue sometimes during walk also, If I use distance filter accuracy is better, But we need to update location after a time interval in minutes(3 min. or 5 min) thats why I am using locationUpdateInterval , but getting issue in accuracy with it and while in still mode interval also get disturbs location update after random intervals
Plugin version:0.6.3
There is no such thing as 0.6.3. Where do you get this version number from?
sorry I have updated the version number , I am using the latest version for both the libraries , Please suggest something for location update interval issue
I have no suggestion for your problem.
it’s recommended to use distanceFilter, it saves energy. Do you know that iOS doesn’t even allow time based location updates?
yes , but Is there any other way that I could know for how long the device is in still mode , so that I can send this to API that device is not moving in this time , then I can use distance Filter also which is giving better accuracy ,As I tested today
but Is there any other way that I could know for how long the device is in still mode
That would be the time-difference between onMotionChange events.
if device is in still mode for 15 minutes then onMotionChange event will occur if device moves after 15 minutes ?
Have you read the wiki “Philosophy of Operation”?
do you understand what Config.stopTimeout is?
do you understand when onMotionChange fires?
yes , but I was just confirming
In the First Image , It is the location when I left from my home on vehicle (at 8:15) and In second screenshot it is the location where I stopped , In between that I didn't got any location , But when I was coming back to home all the locations are uploaded
Looks good to me.
But after 8:15 I got only one location at 8:23 , What could be the reason of that gap ? Now I am using distance filter
I have no idea. Why don’t you fetch the logs from the plug-in with .emailLog method and see what the plug-in was saying in its logs?
See wiki Debugging
I have no idea. Why don’t you fetch the logs from the plug-in with .emailLog method and see what the plug-in was saying in its logs?
ok
69ce9530-d4e6-41f2-8035-3b90d5653bcf.gz
I am not able to read the error from logs , please help me here
The file is gzipped. You need to unzip it.