Skip to content

[Bug]:iOS: getCurrentPosition returns stale Location older than maximumAge after upgrading to v5 #1691

Description

@goblinss

Required Reading

  • Confirmed

Plugin Version

5.2.0

Flutter Doctor

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.35.1, on macOS 26.5.1 25F80 darwin-arm64, locale ja-JP)
[✓] Android toolchain - develop for Android devices (Android SDK version 36.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 26.5)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2026.1)
[✓] VS Code (version 1.124.0)
[✓] Connected device (3 available)
[✓] Network resources

• No issues found!

Mobile operating-system(s)

  • iOS
  • Android

Device Manufacturer(s) and Model(s)

iPhone 16

Device operating-systems(s)

iOS 26.5

What happened?

After upgrading from v4.x to v5.x, on iOS only, BackgroundGeolocation.getCurrentPosition() sometimes returns a very old cached Location.

Android does not exhibit this issue.

Configuration

final location = await BackgroundGeolocation.getCurrentPosition(
samples: 1,
timeout: 10,
persist: false,
maximumAge: 3000,
desiredAccuracy: 10,
);

Expected behavior

A Location older than 3000ms should not be returned when maximumAge: 3000 is specified.

I would expect either:

  1. A newly acquired Location, or
  2. A timeout/error if a fresh Location cannot be obtained.

Actual behavior

The returned Location contains:

{
"age": 1165.985,
"timestamp": "2026-06-12T04:55:46.516+00:00",
"accuracy": 5,
"latitude": 35.6136696922811,
"longitude": 139.7415213266829
}

getCurrentPosition() was called around:

2026-06-12T05:15:12Z

The returned Location is approximately 19 minutes old, despite maximumAge: 3000.

Additional observations

  • This behavior started after migrating from v4.x to v5.x.
  • iOS only.
  • Android returns fresh Locations (age < 1 second) using the same code.
  • The stale Location keeps the same timestamp, while only age increases over time.
  • Repeated calls to getCurrentPosition() continue to return the same stale Location.

Is this expected behavior in v5, or could this be a regression related to maximumAge handling on iOS?

Plugin Code and/or Config

bg.Config(
      http: bg.HttpConfig(
        url: "https:www.example.com",
        method: 'POST',
        autoSync: true,
        batchSync: true,
        autoSyncThreshold: 3,
        maxBatchSize: 6,
        timeout: 60000,
      ),
      persistence: bg.PersistenceConfig(maxDaysToPersist: 14),
      geolocation: bg.GeoConfig(
        locationAuthorizationRequest: 'Always',
        desiredAccuracy: bg.DesiredAccuracy.high,
        distanceFilter: 200,
        pausesLocationUpdatesAutomatically: true,
        showsBackgroundLocationIndicator: true,
        activityType: bg.ActivityType.otherNavigation,
      ),

      app: bg.AppConfig(stopOnTerminate: false, startOnBoot: true),

      logger: bg.LoggerConfig(debug: false, logLevel: bg.LogLevel.warning),
    )

Relevant log output

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingstale

    Type

    No type

    Fields

    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