I am trying to use this plugin for a fitness tracking app. From what I have read in the docs it works as "expected", which is after the plugin has started I need to move a few hundred meters before I am starting to get positions. My use case is that the user presses a button in the app to start recording the path and I need positions of the first 200 meters as well.
I have seen that it is possible to force positions before the plugin starts to automatically getting positions, my question lies in what approach is the best one. Hopefully there is some configuration option to initially getting positions as well but I have not seen one, so I suspect not.
Is this plugin ment to be used for both background and foreground geolocation? Or am I supposed to use this in combination with expo-location for instance?
With only the BackgroundGeolocation.onLocation listener, and if I stand still, I get two location objects initially. And if I never move, I don't get any more locations. This means that I never get good accuracy either since the first location objects most often have bad accuracy. I get one object with sample: true and one object with event: motionchange.
which will trigger more onLocation executions and most often with better accuracy.
It is also possible to set
heartbeatInterval: 1,
preventSuspend: true,
in the configuration and then executing BackgroundGeolocation.getCurrentPosition({}); within the onHeartbeat listener, this will also trigger location events when standing still initially.
These solutions seems to be workarounds rather than great solutions so I wonder how I am supposed to do this? Or is it just not something that this plugin is ment to do?
For fitness tracking it is crucial to have position tracking active before starting to move, I get that this might not be as important in other use cases.
I am trying to use this plugin for a fitness tracking app. From what I have read in the docs it works as "expected", which is after the plugin has started I need to move a few hundred meters before I am starting to get positions. My use case is that the user presses a button in the app to start recording the path and I need positions of the first 200 meters as well.
I have seen that it is possible to force positions before the plugin starts to automatically getting positions, my question lies in what approach is the best one. Hopefully there is some configuration option to initially getting positions as well but I have not seen one, so I suspect not.
Is this plugin ment to be used for both background and foreground geolocation? Or am I supposed to use this in combination with expo-location for instance?
With only the
BackgroundGeolocation.onLocation
listener, and if I stand still, I get two location objects initially. And if I never move, I don't get any more locations. This means that I never get good accuracy either since the first location objects most often have bad accuracy. I get one object withsample: true
and one object withevent: motionchange
.Possible "solutions":
I can do something like this:
which will trigger more onLocation executions and most often with better accuracy.
It is also possible to set
in the configuration and then executing
BackgroundGeolocation.getCurrentPosition({});
within the onHeartbeat listener, this will also trigger location events when standing still initially.These solutions seems to be workarounds rather than great solutions so I wonder how I am supposed to do this? Or is it just not something that this plugin is ment to do?
For fitness tracking it is crucial to have position tracking active before starting to move, I get that this might not be as important in other use cases.
Your Environment
react-native -v
): 0.74.2Expected Behavior
Getting positions initially without moving too much
Actual Behavior
User has to move a few hundred meters before it starts to receive locations.
Steps to Reproduce
1. 2. 3. 4.
Context
Getting better initial positions.
Debug logs
Logs
``` PASTE_YOUR_LOGS_HERE ```