1

I do not understand, I set PausesLocationUpdatesAutomatically to true, don't move the phone and after I call startUpdatingLocation the locationmanager never pause :( what did I miss ?

AllowsBackgroundLocationUpdates = true;
PausesLocationUpdatesAutomatically = true;
requestAlwaysAuthorization
startUpdatingLocation

I continuously receive DidUpdateLocations but no DidPauseLocationUpdates

zeus
  • 12,173
  • 9
  • 63
  • 184

2 Answers2

1

Try to set activityType of your CLLocationManager to automotiveNavigation. Default other is set

gaRik
  • 607
  • 6
  • 10
1

How long did you wait? I had a similar case for when my authorizationStatus was set to requestWhenInUseAuthorization I was working for and it took roughly 16-17 minutes for it to pause. During that time even if the phone was sitting on my desk I was usually still getting updates sent to my didUpdateLocation method. If I remember correctly upon putting the app into background I was getting 2 location updates at the first few seconds I placed it the background and then like two updates at minute 1, another two updates at minute 5, another two at minute 10, another two at minute 14 and eventually another two before 17 and then the pause would happen. I guess the app is receiving the callbacks which check to 'make sure you've actually paused'

Though I didn't set the activityType to automotiveNavigation. I'm assuming setting to that will reduce the time it takes to find out it has to fire the locationManagerDidPauseLocationUpdates callback.

Additionally the callback you will get is locationManagerDidPauseLocationUpdates this. You said DidPauseLocationUpdates but I'm guessing you're talking about the same thing...

mfaani
  • 33,269
  • 19
  • 164
  • 293
  • so if we need to wait 15 min to see the pause it's a little useless because it drain batery for nothing and also it's show a warning to the user "app xxx is using your location in the background" :( so better to stop ourself the locationupdate and restart it ourself later ... no ? – zeus Jul 19 '17 at 21:06
  • @loki 15 minutes of draining the battery is much better than infinite amount of time which means your battery dies much sooner. You could do the stop/start thing following [this](https://stackoverflow.com/questions/6347503/how-do-i-get-a-background-location-update-every-n-minutes-in-my-ios-application) or [this](https://stackoverflow.com/questions/19042894/periodic-ios-background-location-updates) – mfaani Jul 20 '17 at 02:57