0

Has anyone else ran into the issue of telling a location manager to defer updates but still get regular location updates via didUpdateLocations?

I have:

  1. Verified that no other app is using location services

  2. Unplugged the device from debugger and MacBook (Verify it is still getting call by logging didUpdateLocations to a file)

  3. Made sure that only one locationManager used in my app.

According to file log:

CoreLocation: Finished deferred updates: success

I think there is nothing wrong but didUpdateLocations still called at the a normal interval of 1Hz.

How can I check if Deferred Location Updates works?

debuggenius
  • 449
  • 5
  • 15
  • From apple doc: `Deferred updates are delivered only when the system enters a low power state. Deferred updates do not occur during debugging because Xcode prevents your app from sleeping and thus prevents the system from entering that low power state.` – Andrea Apr 01 '16 at 08:45

1 Answers1

0

Be sure to follow all the steps to setup deferred location updates. You can detect if it's works when you get callbacks on didUpdateLocations where the array has more than one location.

Community
  • 1
  • 1
progrmr
  • 75,956
  • 16
  • 112
  • 147
  • Thanks for your response. What does that mean if getting log "CoreLocation: Finished deferred updates: success" and receiving locations one by one at interval of 1s? – debuggenius Apr 05 '16 at 02:08
  • It means that something is keeping iOS from going into the low power state (CPU suspended). Another app in the background or something. – progrmr Apr 05 '16 at 19:05
  • I see the same problem: no errors (reported at time intervals corresponding to the timeout value in allowDeferredLocationUpdatesUntilTraveled:timeout:), but still no deferred updates (a single one every second instead). I tried to kill all other apps and disabled all kinds of background tasks inside my app, but so far nothing helped. Any hints on what exactly could prevent the low power state (or how to find it) would be appreciated. – LPG May 11 '16 at 21:10
  • Update to the above comment: I finally found out what prevented the deferred updates in my own app: I was saving the locations to a CoreData storage. It turned out that it is safe to do that, but one must not call [context save:&error] on the NSManagedObjectContext in didUpdateLocations, as this appears to prevent iOS from entering the low power state. Only call it in didFinishDeferredUpdatesWithError. – LPG Jun 08 '16 at 20:10