react-native-background-geolocation
react-native-background-geolocation copied to clipboard
Android devices collect data sporadically
Your Environment
- Plugin version: 4.14.4
- Platform: Android
- OS version: 12.1
- Device manufacturer / model: Oppo A17K
- React Native version (
react-native -v
): 0.72.3 - Plugin config
const initBackgroundGeolocation = useCallback(async () => {
// Ready the SDK and fetch the current state.
await BackgroundGeolocation.ready({
httpRootProperty: '.',
// Debug
reset: true,
debug: false,
logLevel: BackgroundGeolocation.LOG_LEVEL_VERBOSE,
// transistorAuthorizationToken: token,
// Geolocation
desiredAccuracy: BackgroundGeolocation.DESIRED_ACCURACY_NAVIGATION,
distanceFilter: 5,
// stopTimeout: 5,
// Permissions
locationAuthorizationRequest: 'Always',
// HTTP & Persistence
autoSync: true,
maxDaysToPersist: 14,
// Application
// stopOnTerminate: false,
// startOnBoot: true,
enableHeadless: true,
disableLocationAuthorizationAlert: true,
disableElasticity: true,
// disableStopDetection: true,
pausesLocationUpdatesAutomatically: false,
disableMotionActivityUpdates: true,
heartbeatInterval: 60,
stopOnTerminate: true,
showsBackgroundLocationIndicator: true,
stopOnStationary: false,
backgroundPermissionRationale: {
title: "Allow access to this device's location in the background",
message:
'In order to track your golf activity in the background, please enable "Allow all the time" location permission',
},
});
setReady(true);
}, []);
const startTracking = async () => {
if (
config.config?.tracking?.serverUrl !== '' &&
config.config?.tracking?.serverUrl !== undefined &&
config.config?.tracking?.serverUrl !== null
) {
await BackgroundGeolocation.setConfig({
url: config.config?.tracking?.serverUrl,
authorization: {
strategy: 'JWT',
accessToken: accessToken!,
},
params: { roundId: roundQuery.data?.id! },
});
}
BackgroundGeolocation.start();
BackgroundGeolocation.changePace(true);
};
Expected Behavior
We tested iOS (iPhone 15) and Android side by side on a golf course. On both devices the app was in the background. We would bring it to the foreground a few times over 4 hours.
Here is what iOS data looks like:
Data was consistently collected over the 4 hours, and battery level drops as expected over that time.
Here is a csv of all the datapoints we received. ios.csv
Actual Behavior
Here is what Android looks like:
Here is a graph of battery level over time:
Another graph on the age of the datapoint over time
You can see that there were 2 periods when it did collect data for +/- 30 minutes each.
The battery level looks a bit strange as it's jumping up and down. It's also correlated to the 'age' of the data point.
I've attached a csv of all the datapoints android.csv
Steps to Reproduce
Context
Trying to track location over a period of about 4 hours while the app is in the background.
Debug logs
Logs
We didn't capture any logs.
Oppo A17K
Oppo tends to be one of the worst performing devices. See https://dontkillmyapp.com
BackgroundGeolocation.start(); >BackgroundGeolocation.changePace(true);
Also, use await
@christocracy thanks for this! arg... this makes so hard to manage Android!
There is another issue though around having 2 coordinate that are exactly the same, but the one's age is 3M (i.e. 50mins). There seems to be quite a lot of that
See wiki "Debugging" and search api docs "Logger". Learn to fetch and analyze the plug-in logs using the .emailLog method.
As for battery level jumping, the I will check to see if the level is being updated when an "old" location is returned.
I suggest you test Android on a Google pixel device, where the Android APIs are guaranteed to work as documented, as your baseline device.
Yeah, for the next test we will make sure we can get the logs :-)
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.