Skip to content

[Bug]: Sometime getting location incorrect #1549

@PFLTech

Description

@PFLTech

Required Reading

  • Confirmed

Plugin Version

^4.16.9

Flutter Doctor

PS D:\project\Attendance APP\latest\PaykoshHRMS> flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 3.24.5, on Microsoft Windows [Version 10.0.19045.6216], locale en-US)
[√] Windows Version (Installed version of Windows is version 10 or higher)
[!] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    X Android SDK file not found: C:\Users\pfl\AppData\Local\Android\Sdk\platforms\android-36\android.jar.
[√] Chrome - develop for the web                                                                          
[!] Visual Studio - develop Windows apps (Visual Studio Community 2022 17.12.4)                                                                                              
    X Visual Studio is missing necessary components. Please re-run the Visual Studio installer for the "Desktop development with C++" workload, and include these components:
        MSVC v142 - VS 2019 C++ x64/x86 build tools
         - If there are multiple build tool versions available, install the latest
        C++ CMake tools for Windows
        Windows 10 SDK
[√] Android Studio (version 2022.2)
[√] VS Code (version 1.102.0)
[√] Connected device (4 available)
[√] Network resources

! Doctor found issues in 2 categories.

Mobile operating-system(s)

  • iOS
  • Android

Device Manufacturer(s) and Model(s)

most of the phones

Device operating-systems(s)

android11+

What happened?

we have purchased this plugin to track employee during work hours and it giving location. but we seen that sometime location we are getting location is incorrect on live server. so we are not sure why its happening.

Plugin Code and/or Config

// Fired whenever a location is recorded
    bg.BackgroundGeolocation.onLocation((bg.Location location) {
      print('[location] - $location');
      // getLocationData(location.coords.latitude, location.coords.longitude);
    });

    // Fired whenever the plugin changes motion-state (stationary->moving and vice-versa)
    bg.BackgroundGeolocation.onMotionChange((bg.Location location) {
      print('[motionchange] - $location');
      print("[onMotionChange] isMoving? ${location.isMoving}");
      // getLocationData(location.coords.latitude, location.coords.longitude);
    });

    // Fired whenever the state of location-services changes.  Always fired at boot
    bg.BackgroundGeolocation.onProviderChange((bg.ProviderChangeEvent event) {
      print('[providerchange] - $event');
    });

    bg.BackgroundGeolocation.onHttp((bg.HttpEvent event) {
      print('[${bg.Event.HTTP}] - $event');
      print('[http] success? ${event.success}, status? ${event.status}');
    });

    bg.BackgroundGeolocation.onConnectivityChange(
        (bg.ConnectivityChangeEvent event) {
      print('[connectivitychange] - $event');
    });

    bg.BackgroundGeolocation.onSchedule((bg.State state) {
      print('[${bg.Event.SCHEDULE}] - $state');
    });

    // Configure the plugin
    bg.BackgroundGeolocation.ready(
      bg.Config(
        locationAuthorizationRequest: 'Always',
        disableLocationAuthorizationAlert: false,
        disableMotionActivityUpdates: false,
        // backgroundPermissionRationale: bg.PermissionRationale(
        //     title: "Give me Location bro",
        //     message: "I want you for testing",
        //     positiveAction: "Click here",
        //     negativeAction: "Don't click here"),
        // stationaryRadius: 200,
        // minimumActivityRecognitionConfidence: 75,
        desiredAccuracy: bg.Config.DESIRED_ACCURACY_HIGH,
        distanceFilter: 250,
        // Set distance filter to 100 meters
        disableElasticity: true,
        preventSuspend: true,
        stopOnTerminate: false,
        startOnBoot: true,
        debug: false,
        logLevel: bg.Config.LOG_LEVEL_VERBOSE,
        foregroundService: true,
        forceReloadOnLocationChange: true,
        geofenceModeHighAccuracy: true,
        forceReloadOnGeofence: true,
        forceReloadOnMotionChange: true,
        isMoving: true,
        locationUpdateInterval: 600000,
        enableHeadless: true,
        showsBackgroundLocationIndicator: true,
        stopOnStationary: false,
        pausesLocationUpdatesAutomatically: false,
        schedule: [],
        //new
        heartbeatInterval: 60,
        // autoSyncThreshold: 5,
        // batchSync: true,
        // maxBatchSize: 10,
        // Server endpoint
        url: Common.domain + "xxxxxxxxx",

        // Authorization header
        headers: header,

        // Parameters to send with each location
        params: {'EmpCode': widget.employeecode},
        // extras: {
        //   "trackingId": trackingID,
        // },

        // Sync and HTTP settings
        autoSync: true,
        // Automatically send locations to the server
        method: 'POST', // HTTP POST method
      ),
    ).then((bg.State state) async {
      if (!state.enabled) {
        // Start the plugin if it's not already running
        // await bg.BackgroundGeolocation.stop();
        // await bg.BackgroundGeolocation.start();
        print("hereee..");
        print(bg.Location);
        print("hereee.....");
      }
      // await bg.BackgroundGeolocation.stop();
    });

Relevant log output

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions