Closed Simoon-F closed 3 weeks ago
What are you using .watchPosition for?
What are you using .watchPosition for?
Timing use . watchPosition
to obtain the latitude and longitude of the current device.
Yes, that’s obvious. But why specifically .watchPosition? That method is meant for short periods of time while your app is in the foreground. You do not need to use that method. Do not use this method for long-term tracking in the background.
All you need to do to use this plug-in is call .start().
See wiki Philosophy of Operation.
Yes, that’s obvious. But why specifically .watchPosition? That method is meant for short periods of time while your app is in the foreground. You do not need to use that method. Do not use this method for long-term tracking in the background.
All you need to do to use this plug-in is call .start().
See wiki Philosophy of Operation.
I called the start
method before calling the watchPosition
method.
In fact, I want to know why setting 10s
execution once will become 20s
.
Why specifically are you using .watchPosition? I want people to avoid using this method.
I have such needs here:
Whether it is the foreground or the background, record longitude and latitude once in 10 seconds and submit api once in 1 minute.
.watchPosition is not designed for long-term use in the background.
call .changePace(true) and implement your own timer to call .getCurrentPosition
.watchPosition is not designed for long-term use in the background.
call .changePace(true) and implement your own timer to call .getCurrentPosition
OK, thank you, I'll continue to study and see.
@christocracy I'm facing with same issue. If I passed interval: 1000
location is triggered every ~10s, if I passed interval: 10000
location is triggered every ~20s. Looks like a bug.
You are not providing any information (plug-in version, platform, device model, etc).
react-native -v
): 0.72.0{
startOnBoot: true,
stopOnTerminate: false,
enableHeadless: true,
autoSync: false,
url: '...',
showsBackgroundLocationIndicator: false,
desiredAccuracy: BackgroundGeolocation.DESIRED_ACCURACY_HIGH,
persistMode: BackgroundGeolocation.PERSIST_MODE_ALL,
distanceFilter: 10,
disableLocationAuthorizationAlert: true,
preventSuspend: false,
useSignificantChangesOnly: false,
logLevel: BackgroundGeolocation.LOG_LEVEL_OFF,
}
BackgroundGeolocation.watchPosition(
location => {
console.log(location);
},
errorCode => {
console.error('watchPosition', errorCode);
},
{
interval: 1000,
desiredAccuracy: BackgroundGeolocation.DESIRED_ACCURACY_HIGH,
},
);
Testing in the simulator is the most accurate way to test timing since it isn't affected by the environment. The timing of interval
(using stopwatch) is correct and exact. There is no guarantee that watchPosition
on an actual device will return a location at the exact interval
, particularly while indoors, where GPS doesn't work.
interval: 1000
interval: 5000
interval: 10000
I understand that intervals could be various, but difference in 10 seconds is too much when interval is 1 second. iPhone simulator has the same behaviour and it doesn't few cases, it works like if interval was set 10 seconds instead of 1 second
Did you see my stop-watch images above? They are perfect.
Yes. Looks like side effects produce this bug. Because I run watchPosition
in clear environment and it works perfectly
What do you mean by "side-effects"?
I don't agree this is a bug.
What are you using .watchPosition for?
"side effects" is my code.
I'm using it for foreground location updates to display user on map.
This issue is stale because it has been open for 30 days with no activity.
This issue was closed because it has been inactive for 14 days since being marked as stale.
Your Environment
react-native -v
): 0.68.7Expected Behavior
watchPosition
is executed every ten seconds.Actual Behavior
Execute once in twenty seconds
The first :
Second time :
Steps to Reproduce
Context
Debug logs
Logs
``` PASTE_YOUR_LOGS_HERE ```