Skip to content

Geolocator plugin can't give me live location stream when I using " forceLocationManager: true, " #1290

Description

@Milan-Verselix

Please check the following before submitting a new issue.

Please select for which platform(s) you need help

  • Android
  • iOS
  • Linux
  • macOS
  • Web
  • Windows

Your question

Geolocator plugin can't give me live location stream when I using " forceLocationManager: true, " and I can't getting location stream in background with this code.

import 'package:flutter/foundation.dart';
import 'package:geolocator/geolocator.dart';

Stream<Position> getLiveGeoLocatorData() {
  LocationSettings locationSettings;

  if (defaultTargetPlatform == TargetPlatform.android) {
    locationSettings = AndroidSettings(
      accuracy: LocationAccuracy.high,
      distanceFilter: 50,
      forceLocationManager: true,
      //(Optional) Set foreground notification config to keep the app alive
      //when going to the background
        foregroundNotificationConfig: const ForegroundNotificationConfig(
          notificationText:
          "Example app will continue to receive your location even when you aren't using it",
          notificationTitle: "Running in Background",
          enableWakeLock: true,
        ),
    );
  } else if (defaultTargetPlatform == TargetPlatform.iOS ||
      defaultTargetPlatform == TargetPlatform.macOS) {
    locationSettings = AppleSettings(
      accuracy: LocationAccuracy.high,
      activityType: ActivityType.automotiveNavigation,
      distanceFilter: 50,
      pauseLocationUpdatesAutomatically: true,
      showBackgroundLocationIndicator: true,
    );
  } else {
    locationSettings = const LocationSettings(
      accuracy: LocationAccuracy.high,
      distanceFilter: 100,
    );
  }

  return Geolocator.getPositionStream(locationSettings: locationSettings);
}

Version

^9.0.2

Metadata

Metadata

Assignees

Labels

P2Important issues not at the top of the work list.platform: androidIssue is related to the Android platform.type: bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions