transistorsoft / transistorsoft/native-background-geolocation
[Help Wanted]: I would like to work the sdk as per batch sync instead of every motion change to avoid multiple API calls
Nobody has claimed this yet.
- Dominant language
- Swift
- Stars
- 54
- Forks
- 23
- PR merge metrics
- No merged PRs in 30d
Description
Required Reading
- Confirmed
SDK Version
com.transistorsoft:tslocationmanager:4.1.9
Mobile operating-system(s)
- iOS
- Android
Device Manufacturer(s) and Model(s)
All devices
Device operating-systems(s)
all OS versions
Build tooling versions
Android 16
What do you require assistance about?
fun initialize(
serverURL: String,
userId: String,
accessToken: String,
tenantName: String,
appVersion: String,
session: Long,
trackerId: String,
onReady: ((String) -> Unit)? = null,
onError: ((String) -> Unit)? = null
) {
scope.launch {
try {
registerDefaultListeners()
val normalizedServerUrl = serverURL.trim()
val normalizedAccessToken = normalizeBearerToken(accessToken)
if (normalizedServerUrl.isBlank()) {
onError?.invoke("Tracking server URL cannot be empty")
return@launch
}
if (normalizedAccessToken.isBlank()) {
onError?.invoke("Tracking access token cannot be empty")
return@launch
}
val locationTemplate = $$"""
{
"timestamp":"<%= timestamp %>",
"driver":"$$userId",
"trackerId":"$$trackerId",
"session":$$session,
"lat":<%= latitude %>,
"lng":<%= longitude %>,
"accuracy":<%= accuracy %>,
"odometer":<%= odometer %>,
"speed":<%= speed %>,
"heading":<%= heading %>,
"altitude":<%= altitude %>,
"altitude_accuracy":<%= altitude_accuracy %>,
"eventSource":"<%= event %>",
"activity":"<%= activity.type %>",
"activityConfidence":<%= activity.confidence %>,
"batteryLevel":"<%= battery.level %>%",
"isCharging":<%= battery.is_charging %>,
"jobStatus":2,
"isMock":<%= mock %>,
"is_moving":<%= is_moving %>,
"event":"<%= event %>",
"meta":"{"appVersion":"$$appVersion","model":"$${Build.BRAND} $${Build.MODEL}","os":"Android","osVersion":"$${Build.VERSION.RELEASE}","accuracy":"<%= accuracy %>","distance":"<%= odometer %>","altitude":"<%= altitude %>","altitude_accuracy":"<%= altitude_accuracy %>","battery":"<%= battery.level %>%","isCharging":"<%= battery.is_charging %>","mock":"<%= mock %>","is_moving":"<%= is_moving %>","sourceType":"ss-trans-sdk","tenantName":"$$tenantName","SIM_provider":"$${DeviceMetaDataUtil.getSimProvider(appContext)}","isAllowReceiveNotification":$${DeviceMetaDataUtil.isNotificationAllowed(appContext)},"isIgnoringBatteryOptimizations":$${DeviceMetaDataUtil.isIgnoringBatteryOptimizations(appContext)},"isLocationServicesEnable":$${DeviceMetaDataUtil.isLocationServicesEnabled(appContext)},"isMobileNetWorkEnable":$${DeviceMetaDataUtil.isMobileNetworkEnabled(appContext)},"isPowerSaverModeOn":$${DeviceMetaDataUtil.isPowerSaverModeOn(appContext)},"isPreciseLocationEnable":$${DeviceMetaDataUtil.isPreciseLocationEnabled(appContext)},"isWifiEnable":$${DeviceMetaDataUtil.isWifiEnabled(appContext)}}"
}
""".trimIndent()
bgGeo.ready {
geolocation.desiredAccuracy =
DesiredAccuracy.HIGH
geolocation.distanceFilter =
50.0f
geolocation.stationaryRadius =
10
activity.disableStopDetection =
false
activity.motionTriggerDelay =
30000
http.url = normalizedServerUrl
http.autoSyncThreshold = 50
http.method = HttpMethod.POST
http.autoSync = false
http.rootProperty = "."
http.headers = mapOf(
"Authorization" to
"Bearer $normalizedAccessToken",
"Content-Type" to
"application/json"
)
http.params = emptyMap()
persistence.persistMode =
PersistMode.ALL
persistence.maxDaysToPersist =
14
http.batchSync = true
http.maxBatchSize = 50
persistence.locationTemplate =
locationTemplate
app.stopOnTerminate = false
app.startOnBoot = true
app.enableHeadless = true
app.headlessJobService =
"com.ss.tslocationmanager.HeadlessTask"
app.heartbeatInterval =
420.0
logger.debug = true
logger.logLevel =
LogLevel.VERBOSE
logger.logMaxDays = 3
}
logHttpConfiguration(
serverUrl = normalizedServerUrl,
accessToken = normalizedAccessToken,
userId = userId,
trackerId = trackerId,
session = session,
tenantName = tenantName,
appVersion = appVersion,
locationTemplate = locationTemplate
)
isReadyCalled = true
Log.i(
HTTP_TAG,
"BGGeo ready completed. " +
"serverUrl=$normalizedServerUrl " +
"batchSync=true maxBatchSize=50 " +
"autoSync=true autoSyncThreshold=1"
)
onReady?.invoke(
"BGGeo ready completed"
)
} catch (exception: Exception) {
Log.e(
HTTP_TAG,
"initialize error: ${exception.message}",
exception
)
onError?.invoke(
exception.message
?: "Unknown initialize error"
)
}
}
[Optional] iOS — Swift Config / Code
[Optional] Android — Kotlin Config / Code
[Optional] 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 at the initialize function and review the Android configuration for http.batchSync, http.maxBatchSize, http.autoSync, and http.autoSyncThreshold. Reconcile the requested batch behavior with the current settings and the contradictory log message, then verify that motion changes do not trigger individual API calls and that locations are sent in batches of the intended size.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, kotlin
- Domain
- mobile-dev
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100