Forráskód Böngészése

explicitely disable pausesLocationUpdatesAutomatically in order to avoid background location tethering issues, reduce the distance filter and simplify loction validation

cyberta 5 éve
szülő
commit
31642beb83
1 módosított fájl, 3 hozzáadás és 9 törlés
  1. 3 9
      deltachat-ios/Helper/LocationManager.swift

+ 3 - 9
deltachat-ios/Helper/LocationManager.swift

@@ -10,10 +10,10 @@ class LocationManager: NSObject, CLLocationManagerDelegate {
     init(context: DcContext) {
         dcContext = context
         locationManager = CLLocationManager()
-        locationManager.distanceFilter = 50
+        locationManager.distanceFilter = 25
         locationManager.desiredAccuracy = kCLLocationAccuracyNearestTenMeters
         locationManager.allowsBackgroundLocationUpdates = true
-        //locationManager.pausesLocationUpdatesAutomatically = true
+        locationManager.pausesLocationUpdatesAutomatically = false
         locationManager.activityType = CLActivityType.fitness
         super.init()
         locationManager.delegate = self
@@ -106,8 +106,7 @@ class LocationManager: NSObject, CLLocationManagerDelegate {
 
         return !isNewLocationOutdated(newLocation: newLocation) &&
             hasValidAccuracy(newLocation: newLocation) &&
-            (isSignificantlyMoreAccurate(newLocation: newLocation, lastLocation: lastLocation) ||
-            isMoreAccurate(newLocation: newLocation, lastLocation: lastLocation) && hasLocationChanged(newLocation: newLocation, lastLocation: lastLocation) ||
+            (isMoreAccurate(newLocation: newLocation, lastLocation: lastLocation) && hasLocationChanged(newLocation: newLocation, lastLocation: lastLocation) ||
             hasLocationSignificantlyChanged(newLocation: newLocation, lastLocation: lastLocation))
     }
 
@@ -115,11 +114,6 @@ class LocationManager: NSObject, CLLocationManagerDelegate {
         return newLocation.horizontalAccuracy >= 0
     }
 
-    func isSignificantlyMoreAccurate(newLocation: CLLocation, lastLocation: CLLocation) -> Bool {
-//        logger.debug("LOCATION isSignificantlyMoreAccurate: \(lastLocation.horizontalAccuracy - newLocation.horizontalAccuracy > 25)")
-        return lastLocation.horizontalAccuracy - newLocation.horizontalAccuracy > 25
-    }
-
     func isMoreAccurate(newLocation: CLLocation, lastLocation: CLLocation) -> Bool {
 //        logger.debug("LOCATION: isMoreAccurate \(lastLocation.horizontalAccuracy - newLocation.horizontalAccuracy > 0)")
         return lastLocation.horizontalAccuracy - newLocation.horizontalAccuracy > 0