Reputation: 10759
I am setting the following, which I would assume would NOT call "didUpdateLocations" according to my parameters, but its calling it about 3 times a second?
self.locationManager.desiredAccuracy = kCLLocationAccuracyBest;
[self.locationManager setActivityType:CLActivityTypeAutomotiveNavigation];
[self.locationManager allowDeferredLocationUpdatesUntilTraveled:15 timeout:3000.0];
After setting "allowDeferredLocationUpdatesUntilTraveled" it is still calling it about 3 times a second?
Upvotes: 3
Views: 2999
Reputation: 4350
You can solve part of your desired outcome - only update if they travel further than 15m - with
self.locationManager.distanceFilter = 15;
From the docs: "The minimum distance (measured in meters) a device must move horizontally before an update event is generated."
Have just used in my iOS7/8 app and seems to work fine in foreground.
For the time between triggering, suggest you use CLLocation timestamp.
Upvotes: 2
Reputation: 2427
when you setActivityType to CLActivityTypeAutomotiveNavigation your telling your app that your a navigation app so will likely be very active. Using the navigation setting will cause your app to use more than just the gps hardware (for example accelerometer). The doc basically says this will drain your battery in an instant and you should plan to have the device plugged in while active.
Also allowDeferredLocationUpdates is for use when your app is backgrounded. It says you care about receiving the location updates but you don't need them in real time so don't wake the app up all the time.
If you want to pause because your not moving try setting pausesLocationUpdatesAutomatically.
Upvotes: 0