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);
}
Please check the following before submitting a new issue.
Please select for which platform(s) you need help
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.
Version
^9.0.2