5

I am wondering if iOS system restarts locationUpdates of CLLocationManager automatically after being paused automatically by the pausesLocationUpdatesAutomatically property or if I have to handle the case by my own.

If yes, according to which rules and if not how to know that I start moving again and should relaunch locationUpdates ?

kokluch
  • 602
  • 5
  • 16

1 Answers1

6

If you set

yourLocationManager.pausesLocationUpdatesAutomatically = YES;

you should also set a value to

yourLocationManager.activityType

"The location manager uses the information in this property as a cue to determine when location updates may be automatically paused. Pausing updates gives the system the opportunity to save power in situations where the user's location is not likely to be changing. For example, if the activity type is CLActivityTypeAutomotiveNavigation and no location changes have occurred recently, the radios might be powered down until movement is detected again."

UPDATE: changed Apple documentation " After a pause occurs, it is your responsibility to restart location services again when you determine that they are needed. Core Location calls the locationManagerDidPauseLocationUpdates(_:) method of your location manager's delegate to let you know that a pause has occurred. In that method, you might configure a local notification whose trigger is of type UNLocationNotificationTrigger and is set to notify when the user exits the current region. The message for the local notification should prompt the user to launch your app again so that it can resume updates."

tanz
  • 2,557
  • 20
  • 31
  • 1
    Well that is not exactly my question. I am already aware of that but thanks anyway. However this : "and they automatically restart when the activityType is not detected anymore" is what I want to know. Could you tell me more about it please ? Where did you find the information ? Thks – kokluch Jan 24 '14 at 15:59
  • 4
    It definitely does if the app is in foreground. If it's in background mode it's likely to never be resumed - as discussed here: http://stackoverflow.com/questions/17484352/iphone-gps-in-background-never-resumes-after-pause – tanz Jan 24 '14 at 16:21
  • All right. Thanks for the link. It seems that there is a lake of documentation about it. – kokluch Jan 24 '14 at 16:48
  • 2
    i don't see anywhere that they automatically restart when the activityType is not detected anymore. in the doc i can read: "After a pause occurs, it is your responsibility to restart location services again when you determine that they are needed" – zeus Jul 17 '17 at 09:46