-
Notifications
You must be signed in to change notification settings - Fork 444
[Help Wanted]: Guidance on Optimal Heartbeat Configuration for Battery Efficiency #2523
Description
Required Reading
- Confirmed
Plugin Version
4.19.2
Mobile operating-system(s)
- iOS
- Android
Device Manufacturer(s) and Model(s)
IPhone 12,13,14,15,16,17
Device operating-systems(s)
IOS 18.1,26.0 and bove
React Native / Expo version
4.19.2
What do you require assistance about?
Hi @christocracy
We are planning to use the heartbeat mechanism in our project and would like to understand the recommended configuration intervals that balance reliable tracking with optimal battery consumption.
Currently, we are testing with the following configuration. In particular, we are using heartbeatInterval on iOS to periodically trigger location updates when the device is stationary.
Could you please review this configuration and suggest the best practice values for heartbeatInterval, distanceFilter, and locationUpdateInterval to ensure efficient battery usage while maintaining reliable tracking?
Below is the configuration currently used in our implementation:
const configBackgroundGeolocation: any = {
debug: TESTING_MODE_ENABLED, // Shows tracking events in logs
heartbeatInterval: Platform.OS === 'ios' ? 120 : 0, // Heartbeat interval when stationary
allowIdenticalLocations: TESTING_MODE_ENABLED,
preventSuspend: true,
pausesLocationUpdatesAutomatically: false,
autoSync: true,
batchSync: true,
desiredAccuracy: BackgroundGeolocation.DESIRED_ACCURACY_NAVIGATION,
autoSyncThreshold: TESTING_MODE_ENABLED ? 1 : 5,
maxBatchSize: 20,
distanceFilter: TESTING_MODE_ENABLED
? 0
: tenant?.tenantMobileConfig?.trackingDistanceFilter ??
DEFAULT_TRACKING_DISTANCE_FILTER,
disableElasticity: true,
elasticityMultiplier: 1,
locationUpdateInterval: TESTING_MODE_ENABLED
? 10000
: userInfo?.mobileConfig?.trackingGetGPSFrequency ??
tenant?.tenantMobileConfig?.trackingGetGPSFrequency ??
DEFAULT_TRACKING_GET_GPS_FREQUENCY,
logLevel: TESTING_MODE_ENABLED
? BackgroundGeolocation.LOG_LEVEL_VERBOSE
: BackgroundGeolocation.LOG_LEVEL_ERROR,
notification: {
title: title,
text: content,
sticky: true,
priority: BackgroundGeolocation.NOTIFICATION_PRIORITY_LOW,
},
stopOnTerminate: false,
startOnBoot: true,
foregroundService: true,
stopOnStationary: false,
showsBackgroundLocationIndicator: true,
locationAuthorizationRequest: 'Always',
headers: {
'Content-Type': 'application/json',
Authorization: Bearer ${userToken},
},
httpRootProperty: '.',
authorization: {
strategy: 'JWT',
accessToken: userToken,
refreshToken: token_refresh,
refreshUrl: token_url,
refreshPayload: {
grant_type: 'refresh_token',
refresh_token: '{refreshToken}',
},
expires: token_expired,
},
enableHeadless: true,
url: ${baseUrl}/api/app-base/vdms-tracking/push,
locationTemplate: locationTemplate,
};
Specifically, we would like clarification on:
What heartbeat interval would you recommend for production use to minimize battery drain?
Are there any recommended values for distanceFilter and locationUpdateInterval when using heartbeat?
Are there any additional configuration flags we should enable or disable to improve efficiency?
Your guidance on best practices for this setup would be greatly appreciated.
Thanks and regards,
Surya