Skip to content

[Bug]: #1673

@harryandroiddev

Description

@harryandroiddev

Required Reading

  • Confirmed

Plugin Version

^5.1.1

Flutter Doctor

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.41.6, on macOS 26.3 25D125 darwin-arm64, locale en-IN)
[✓] Android toolchain - develop for Android devices (Android SDK version 36.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 26.2)
[✓] Chrome - develop for the web
[✓] Connected device (4 available)
[✓] Network resources

• No issues found!

Mobile operating-system(s)

  • iOS
  • Android

Device Manufacturer(s) and Model(s)

iphone 15

Device operating-systems(s)

26.3.1 (a)

What happened?

While tracking location in terminate state the onmotionchange event is not fired when stop the trip .

  • Opened the app start the tracking .
  • Motion changed event fire for the stationary location and also fetched the location updates .
  • Started moving the motion change event fires again with is moving true and start getting location updates while travelling .
  • Reached the destination after 1 hour of travelling , the stop timeout notification shown up with 300 s which is default timeout but event after 10 min of time passed the motion update event is not fired in the app .
  • Also there is no location turn off notification shown up . just gets the event as onlocation even with moving as true .

Summary : We are syncing the data manually and storing too , so when the tracking start saving location data locally on device, when motion event is fired we sync the remaining data at once . But the event never fires so our data remains in the local storage only .

Plugin Code and/or Config

static Future<void> init() async {
    // 1. Listen for Heartbeats while app is open

    if (Platform.isAndroid) {
      bg.BackgroundGeolocation.onHeartbeat(_handleHearBeat);
    }

    bg.BackgroundGeolocation.onMotionChange(_handleMotionChange);

    bg.BackgroundGeolocation.onLocation(
      _handleLocationChange,
      _handleLocationError,
    );

    // 2. Configure the plugin
    await bg.BackgroundGeolocation.ready(
      bg.Config(
        app: bg.AppConfig(
          backgroundPermissionRationale: bg.PermissionRationale(
            message:
                "Allow background location access so we can track your attendance while the app runs in the background.",
          ),
          stopOnTerminate: false, // Keep service running after swipe-up
          startOnBoot: true, // Start service on phone reboot
          enableHeadless: true, // Enable the HeadlessTask above
          heartbeatInterval: 60, // 1 Minute Heartbeat]
          preventSuspend: false, // For ios only
          notification: bg.Notification(
            title: "Nebero ERP Tracking",
            text: "Location tracking is active",
            color: "#2196F3",
          ),
        ),

        geolocation: bg.GeoConfig(
          locationUpdateInterval: Duration(
            minutes: 10,
          ).inMilliseconds, //Update location on interval Android
          disableElasticity: Platform.isAndroid ? true : false,
          showsBackgroundLocationIndicator: false,
          desiredAccuracy: bg.DesiredAccuracy.high,
          distanceFilter: Platform.isAndroid ? 0 : 50,
        ),
        persistence: bg.PersistenceConfig(persistMode: bg.PersistMode.none),
        activity: bg.ActivityConfig(),
        logger: bg.LoggerConfig(
          debug:
              true, // Plays sound/vibrates on events (turn off for production)
          logLevel: bg.LogLevel.debug,
        ),

        // ─── TIMING ───
      ),
    ).then((bg.State state) {
      debugPrint('[BgLocation] Plugin Ready. Enabled: ${state.enabled}');
    });
  }

Relevant log output

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions