transistorsoft / transistorsoft/react-native-background-geolocation
[Bug]: locationTemplate not applied in all cases
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 2.9k
- Forks
- 446
- PR merge metrics
- No merged PRs in 30d
Description
Required Reading
- Confirmed
Plugin Version
5.4.0
Mobile operating-system(s)
- iOS
- Android
Device Manufacturer(s) and Model(s)
Samsung S24 FE
Device operating-systems(s)
Android 16
React Native / Expo version
0.86.2
What happened?
On our server we're receiving messages that are not in compliance with the locationTemplate.
Plugin Code and/or Config
const LOCATION_TEMPLATE = '{"timestamp": "<%= timestamp %>", "latitude": <%= latitude %>, "longitude": <%= longitude %>, "accuracy": <%= accuracy %>, "speed": <%= speed %>}';
{
geolocation: {
desiredAccuracy:
BackgroundGeolocation.DesiredAccuracy.High,
// When any motion-type activity is detected (eg: on_foot),
// the plugin will enter the moving state, turn location-services on and begin recording
// a location each distanceFilter meters.
// default: 10
distanceFilter: user
? user.tenant.settings.locationService
.distanceFilter
: 50,
// Activity Recognition
// https://github.com/transistorsoft/react-native-background-geolocation/wiki/Philosophy-of-Operation#stoptimeout
// When the MotionActivity API first reports an activity of still,
// the plugin will engage its "stop-detection" system. This system involves initiating
// a timer of stopTimeout minutes. When this timer finally expires,
// the plugin will enter the stationary state. If the MotionActivity API reports
// a moving-type activity before the timer times-out, the stopTimeout timer will
// be cancelled and stop-detection will be cease -- the plugin will remain in the moving state.
// default: 5
stopTimeout: user
? user.tenant.settings.locationService.stopTimeout
: 15,
activityType:
BackgroundGeolocation.ActivityType
.AutomotiveNavigation,
locationAuthorizationRequest: "Always",
disableLocationAuthorizationAlert: true,
},
app: {
enableHeadless: false, // Not needed since stopOnTerminate handles this for us.
stopOnTerminate: false, // Allow the background-service to continue tracking when user closes the app.
startOnBoot: false,
backgroundPermissionRationale: {
title: "Allow {applicationName} to access to this device's location in the background?",
message:
"In order to track your activity in the background, please enable {backgroundPermissionOptionLabel} location permission",
positiveAction:
"Change to {backgroundPermissionOptionLabel}",
negativeAction: "Cancel",
},
},
logger: {
debug: __DEV__,
logLevel: __DEV__
? BackgroundGeolocation.LogLevel.Debug
: BackgroundGeolocation.LogLevel.Warning,
},
http: {
url: postUrl,
batchSync: false,
autoSync: true,
method: "POST",
rootProperty: ".",
headers: {
Authorization: `token ${token}`,
},
},
persistence: {
locationTemplate: LOCATION_TEMPLATE,
},
};
Event sent to the postUrl:
{
"activity": {
"activities": [
"still"
],
"confidence": 100,
"type": "still"
},
"age": 13.687,
"battery": {
"is_charging": false,
"level": 0.51
},
"coords": {
"accuracy": 15.53,
"altitude": 49.9,
"altitude_accuracy": 0.67,
"ellipsoidal_altitude": 49.9,
"heading": -1,
"heading_accuracy": -1,
"latitude": 51.0000000,
"longitude": 5.0000000,
"speed": -1,
"speed_accuracy": -1
},
"is_moving": true,
"odometer": 15139777.58,
"odometer_error": 783.58,
"recorded_at": "2026-09-10T07:16:38.283Z",
"timestamp": "2026-09-10T07:16:24.598Z",
"uuid": "459f0fc8-c0f4-4ad5-989c-2d527361e3c9"
}
Relevant log output
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the Android behavior with the supplied React Native configuration, especially persistence.locationTemplate and the event sent to postUrl. Trace how locationTemplate is applied to outgoing events and compare the generated payload with the configured fields; done means every relevant event sent to the server follows the template.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- react-native, typescript
- Domain
- mobile
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 54/100