react-native-background-geolocation icon indicating copy to clipboard operation
react-native-background-geolocation copied to clipboard

Got multiple records (latitude, longtitude and timestamp ) when user switching between internet connections

Open Nishad013 opened this issue 11 months ago • 3 comments

Your Environment

System: OS: macOS 14.4 CPU: (8) arm64 Apple M2 Memory: 122.48 MB / 8.00 GB Shell: 5.9 - /bin/zsh Binaries: Node: 16.20.2 - ~/.nvm/versions/node/v16.20.2/bin/node Yarn: 1.22.21 - ~/Documents/GitHub/alt-tomrex-app/node_modules/.bin/yarn npm: 8.19.4 - ~/.nvm/versions/node/v16.20.2/bin/npm Watchman: 2024.01.22.00 - /opt/homebrew/bin/watchman Managers: CocoaPods: 1.15.0 - /opt/homebrew/bin/pod SDKs: iOS SDK: Platforms: DriverKit 23.2, iOS 17.2, macOS 14.2, tvOS 17.2, visionOS 1.0, watchOS 10.2 Android SDK: Not Found IDEs: Android Studio: 2023.1 AI-231.9392.1.2311.11330709 Xcode: 15.2/15C500b - /usr/bin/xcodebuild Languages: Java: 15.0.2 - /usr/bin/javac npmPackages: @react-native-community/cli: Not Found react: 16.13.1 => 16.13.1 react-native: ^0.64.0 => 0.64.4 react-native-macos: Not Found npmGlobalPackages: react-native: Not Found

  • Plugin version: "react-native-background-geolocation": "^4.15.0"
  • Platform: iOS or Android : both device ios and android(realme 7pro android version 12.0) and ios(iphone 12)
  • OS version: android 12.0
  • Device manufacturer / model: realme 7pro
  • React Native version (react-native -v): 0.64.0
  • Plugin config
      const state = await BackgroundGeolocation.ready({
        // url: 'https://655469d763cafc694fe66d97.mockapi.io/getLocation',
        url: API_URL + API_ENDPOINTS.SAVELOCATION,
        logLevel: BackgroundGeolocation.LOG_LEVEL_VERBOSE,
        desiredAccuracy: BackgroundGeolocation.DESIRED_ACCURACY_HIGH,
        distanceFilter: 1,
        stopTimeout: 5,
        locationTemplate:
          '{"Latitude":<%= latitude %>,"Longitude":<%= longitude %>,"TimeStamp": "<%= timestamp %>"}',
        locationAuthorizationRequest: 'Always',
        backgroundPermissionRationale: {
          title:
            "Allow {applicationName} to access this device's location even when closed or not in use.",
          message:
            'This app collects location data to enable recording your trips to work and calculate distance-travelled.',
          positiveAction: 'Change to "{backgroundPermissionOptionLabel}"',
          negativeAction: 'Cancel',
        },
        headers: {
          authorization: 'Bearer ' + getToken.data.Token,
          source: source,
        },
        params: {
          ClientId: respo_storage.data.ClientId,
        },
        batchSync: true,
        autoSync: true,
        maxDaysToPersist: 14,
        stopOnTerminate: false,
        startOnBoot: true,
        enableHeadless: true,
        // maxBatchSize: 10000,
        // autoSyncThreshold: 10,
      });

Expected Behavior

when the application has stable network connection then it sync location to configured url with every entry it gets from device and lock any duplicate entry in SQlite

Actual Behavior

while testing the application in release mode we have encounter an problem where we get multiple records with same (latitude, longtitude and timestamp ) in database and this problem occurs when the user is switching the internet connection on every 100-200 meter walk like user walk 200 meter with cellular connection on and after 200 meter walk it off . this process is repeated 4-5 times .

Steps to Reproduce

  1. just try switching between cellular network repeatedly (if anyone face the same and resolved it please let me know ) image_2024_03_18T07_12_59_782Z

Context

we want to track the person location

Debug logs

As im tested this in release mode so i didn't get any logs

Nishad013 avatar Mar 18 '24 07:03 Nishad013

The plug-in emits an onProviderChange event each time the location provider changes. The plug-in also records a location with event: “providerchange". Some apps like to know where/when a user might have disabled location-services.

this can be disabled (see api docs Config.disableProviderChangeRecord).

christocracy avatar Mar 18 '24 12:03 christocracy

Okay i got it what you are trying to say just tell me if i'm not getting it wrong let i switch off the internet at 9:15:00am till 9:25:00am then it has to record the data when the internet connection is switched like 9:15:00am only and not for whole time till the connection is switched of RIGHT? ONLY 9:15:00am record has to come twice not the records from 9:15:00am to 9:25:00am CORRECT ME IF I'm WRONG

Nishad013 avatar Mar 22 '24 10:03 Nishad013

This issue is stale because it has been open for 30 days with no activity.

github-actions[bot] avatar Apr 22 '24 01:04 github-actions[bot]

This issue was closed because it has been inactive for 14 days since being marked as stale.

github-actions[bot] avatar May 06 '24 01:05 github-actions[bot]