Skip to content

feat(location): unify LocationManager.asLocationSource() fallback and permission semantics across Android and iOS #1818

Description

@dkhawk

Context

In the initial multiplatform LocationSource implementation (#1817) and the maps-compose-multiplatform-demo integration (googlemaps/android-maps-compose#1038), iOS callers can create a LocationSource with a single call (manager.asLocationSource()), whereas Android callers currently need extra wrapper logic around LocationManager to handle cached fixes, indoor fallback, and Android 12+ coarse-only permissions.

Proposed Enhancements

  1. Built-in Cached Fix & Coarse Fallback in LocationManager.asLocationSource() (androidMain):

    • Emit the freshest cached location across GPS_PROVIDER, NETWORK_PROVIDER, and PASSIVE_PROVIDER (each wrapped in try / catch (_: SecurityException)) when collection begins, matching CLLocationManager.startUpdatingLocation() on iOS.
    • For LocationPriority.HIGH_ACCURACY, merge fineLocationEvents (GPS_PROVIDER) and coarseLocationEvents (NETWORK_PROVIDER). Because fineLocationEvents catches SecurityException and closes cleanly when only ACCESS_COARSE_LOCATION ("Approximate" location on Android 12+) is granted, merging the two allows LocationManager.asLocationSource() to:
      • Automatically degrade to NETWORK_PROVIDER when the user grants "Approximate" location instead of "Precise".
      • Deliver indoor network fixes while waiting for a GPS satellite lock.
      • Close cleanly if neither fine nor coarse permission is granted.
    • This reduces Android LocationSource creation in consumer apps to a single line (manager.asLocationSource()), matching iOS.
  2. Automatic Authorization Prompt on kCLAuthorizationStatusNotDetermined in CLLocationManager.locationEvents() (iosMain):

    • When authorizationStatus == kCLAuthorizationStatusNotDetermined, invoke requestWhenInUseAuthorization() before startUpdatingLocation() so collecting the flow on iOS triggers the system permission prompt and begins emitting as soon as the user grants permission.
  3. Shared Compose Permission Helper (maps-compose-multiplatform):

    • Provide a reusable @Composable permission/location helper using LifecycleEventEffect(Lifecycle.Event.ON_RESUME) and ActivityResultContracts.RequestMultiplePermissions on Android alongside CLLocationManagerDelegateProtocol.locationManagerDidChangeAuthorization on iOS.

Activity

  1. added
    priority: p2Moderately-important priority. Fix may not be included in next release.
    on Oct 9, 2026
  2. added a commit that references this issue on Oct 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority: p2Moderately-important priority. Fix may not be included in next release.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions