Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce location tracking accuracy #185

Merged
merged 1 commit into from
Dec 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -461,4 +461,4 @@ SPEC CHECKSUMS:

PODFILE CHECKSUM: 9bf7626a50066852dd21123c4db8e9fe30622485

COCOAPODS: 1.15.2
COCOAPODS: 1.16.2
1 change: 0 additions & 1 deletion app/ios/Runner/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ extension AppDelegate {
(call: FlutterMethodCall, result: @escaping FlutterResult) in
guard self != nil else { return }
if call.method == "startTracking" {
print("XXX startTracking method invoked")
LocationManager.shared.startLocationUpdates()
result(true)
} else if call.method == "stopTracking" {
Expand Down
4 changes: 2 additions & 2 deletions app/ios/Runner/LocationManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class LocationManager: NSObject, ObservableObject, CLLocationManagerDelegate {

private var manager: CLLocationManager
private var trackingInvoked: Bool = false
private let distanceThreshold: CLLocationDistance = 10.0
private let distanceThreshold: CLLocationDistance = 100.0

@Published var lastLocation = CLLocation()

Expand All @@ -23,7 +23,7 @@ class LocationManager: NSObject, ObservableObject, CLLocationManagerDelegate {
super.init()
manager.delegate = self
manager.distanceFilter = distanceThreshold
manager.desiredAccuracy = kCLLocationAccuracyNearestTenMeters
manager.desiredAccuracy = kCLLocationAccuracyHundredMeters
manager.allowsBackgroundLocationUpdates = true
manager.pausesLocationUpdatesAutomatically = false
}
Expand Down
8 changes: 5 additions & 3 deletions data/lib/repository/journey_repository.dart
Original file line number Diff line number Diff line change
Expand Up @@ -365,10 +365,12 @@ class JourneyRepository {
LocationData extractedLocation,
String userId,
) async {
var lastFiveLocations =
locationCache.getLastFiveLocations(userId).take(4).toList();
lastFiveLocations.insert(0, extractedLocation);
var lastFiveLocations = locationCache.getLastFiveLocations(userId).toList();

if (lastFiveLocations.length >= 5) {
lastFiveLocations.removeAt(0);
}
lastFiveLocations.add(extractedLocation);
locationCache.putLastFiveLocations(lastFiveLocations, userId);
}

Expand Down
Loading