Skip to content

[Help Wanted]: Duplicate data + maxDaysToPersist bug + battery bug #1637

@Chewbacca-14

Description

@Chewbacca-14

Required Reading

  • Confirmed

Plugin Version

5.0.3

Mobile operating-system(s)

  • iOS
  • Android

Device Manufacturer(s) and Model(s)

Doogee Blade 10, Samsung A54

Device operating-systems(s)

Android 14, Android 15

What do you require assistance about?

Image

Hi, I would like to ask a few questions regarding a Flutter background geolocation issue.

First question – duplicate locations

I am seeing duplicated locations. In the screenshot (or at
https://tracker.transistorsoft.com/adaptine — blade-10-doogee (Flutter)), on 2/11 at 19:08:54.479, you can see about 14 identical locations that were sent on 2/12 at 09:12.

I am using the original Flutter Background Geolocation example app for testing.
Why do I receive 14 identical locations from the original app? The same behavior also occurs in my own Flutter app, even though allowIdenticalLocations is set to false.

Second question – logMaxDays / maxDaysToPersist
How is it possible that I have both logMaxDays and maxDaysToPersist set to 2, but locations from 2/1 are still being sent on 2/7?

Third question – battery value changing
How is it possible that when an HTTP request fails (for example due to a server error), the request is saved to the local database with a battery value of 77%, but when it is sent 2 hours later (after the server is available again), the battery value sent is 55%?

Why does the battery value in the saved record change to the current battery level instead of preserving the value from the original time when the location was recorded?

Thank you

[Optional] Plugin Code and/or Config

bg.Config(
      geolocation: GeoConfig(
        allowIdenticalLocations: false, // [Android only] Allow recording locations which are duplicates of the previous.
        fastestLocationUpdateInterval: 7000, // [Android only] Explicitly set the fastest interval for location updates, in milliseconds.
        locationUpdateInterval: 4000, // [Android only] Set the desired interval for active location updates, in milliseconds.
        locationTimeout: 13, // The default timeout in seconds when requesting a location before the SDK gives up and fires a [LocationError].
        desiredAccuracy: DesiredAccuracy.high, // Specify the desired-accuracy of the geolocation system.
        disableElasticity: false, // Disable automatic, speed-based [distanceFilter] scaling.
        elasticityMultiplier: 1.8, // [Android only] The multiplier applied to the [distanceFilter] when the device is moving.
        distanceFilter: 10, // The minimum distance (measured in meters) a device must move horizontally before an update event is generated.
        geofenceProximityRadius: 1000,
        stopAfterElapsedMinutes: 0,
        disableLocationAuthorizationAlert: true, // Disables automatic authorization alert when plugin detects the user has disabled location authorization.
        locationAuthorizationRequest: 'Always', // Defines the desired location-authorization request you wish for the user to authorize:
        stopTimeout: 7, // Minutes to wait in moving state with no movement before considering the device stationary.
      ),
      http: HttpConfig(
        url: globals.graphqlUrl,
        method: 'POST',
        rootProperty: ".",
        timeout: 60000, // HTTP request timeout in milliseconds.
        headers: {
          'Content-Type': 'application/json',
          'Authorization': 'Bearer $apiToken',
        },
        autoSync: true,
        autoSyncThreshold: 3,
        batchSync: true,
        maxBatchSize: 3,
      ),
      logger: LoggerConfig(
        logLevel: LogLevel.verbose, // Controls the volume of recorded events in the plugin's logging database.
        logMaxDays: 2, // Maximum number of days to persist a log-entry in database.
        debug: false, // Configure the plugin to emit sound effects and local-notifications during development.
      ),
      activity: ActivityConfig(
        motionTriggerDelay: 0, // [Android only] Optionally add a delay in milliseconds to trigger Android into the moving state when Motion API reports the device is moving
        stopOnStationary: false, // Automatically [BackgroundGeolocation.stop] when the [stopTimeout] elapses.
        disableMotionActivityUpdates: false, // Disable the plugin requesting "Motion & Fitness" (ios) or "Physical Activity" (android >= 10) authorization from the User.
      ),
      app: AppConfig(
        preventSuspend: true, // [iOS only] Prevent iOS from suspending your application in the background after location-services have been switched off.
        heartbeatInterval: 60, // Controls the rate (in seconds) the [BackgroundGeolocation.onHeartbeat] event will fire.
        // Before an iOS app terminates, the plugin will ensure that a stationary geofence of [stationaryRadius] meters is created around the last known position.
        // When the user moves beyond the stationary geofence (typically ~200 meters), iOS will completely reboot your application in the background,
        // including your Flutter application and the plugin will resume tracking.
        //iOS maintains geofence monitoring at the OS level, in spite of application terminate / device reboot.
        stopOnTerminate: false, // Controls whether to continue location-tracking after application is terminated.

        // iOS cannot immediately engage tracking after a device reboot.
        // Just like [stopOnTerminate]:false, iOS will not re-boot your app until the device moves beyond the stationary geofence around the last known location.
        // In addition, iOS subscribes to "background-fetch" events, which typically fire about every 15 minutes — these too are capable of rebooting your app after a device reboot.
        startOnBoot: true, // Controls whether to resume location-tracking after device is rebooted.
        notification: _bgNotification(context), // (Android only) Configure the persistent foreground notification.
        backgroundPermissionRationale: _bgPermissionRationale(context), // (Android 11+) Configure the dialog presented to the user when Always location permission is requested.
        enableHeadless: true,
      ),
      persistence: PersistenceConfig(
        maxDaysToPersist: 2, // Maximum number of days to store a geolocation in plugin's SQLite database.
        locationsOrderDirection: 'DESC', // Controls the order that locations are selected from the database (and uploaded to your server).
        persistMode: PersistMode.location, // Allows you to specify which events to persist to the SDK's internal database: locations | geofences | all (default).
        locationTemplate: locationTemplate,
      ),

      foregroundService: true, // [Android only] Configure the plugin service to run as a more robust "Foreground Service".
      isMoving: true, // Configure the initial tracking-state after [BackgroundGeolocation.start] is called.
    );

[Optional] Relevant log output

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions