Reputation: 47
startMonitoringSignificantLocationChanges
is added for background and delegate "- (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations
" is called in every 47 sec
while application in background.
If application is on same place i don't want to hit the server api to submit the location, if location has changed then I want to submit the lat& long to server.
It's drain the iphone battery. I want to save battery drain which occured by our application.
Please suggest.
Upvotes: 1
Views: 363
Reputation: 1966
You need to set the desiredAccuracy, distanceFilter, headingFilter(if you need it) properly, where you have initialised locationmanager.
/* Pinpoint our location with the following accuracy:
*
* kCLLocationAccuracyBestForNavigation highest + sensor data
* kCLLocationAccuracyBest highest
* kCLLocationAccuracyNearestTenMeters 10 meters
* kCLLocationAccuracyHundredMeters 100 meters
* kCLLocationAccuracyKilometer 1000 meters
* kCLLocationAccuracyThreeKilometers 3000 meters
*/
self.your_locationManager_object.desiredAccuracy = kCLLocationAccuracyNearestTenMeters;
/* Notify changes when device has moved x meters.
* Default value is kCLDistanceFilterNone: all movements are reported.
*/
self.locationManager.distanceFilter = 10.0f;
/* Notify heading changes when heading is > 5.
* Default value is kCLHeadingFilterNone: all movements are reported.
*/
self.locationManager.headingFilter = 5;
// update location
if ([CLLocationManager locationServicesEnabled]){
[self.locationManager startUpdatingLocation];
}
Upvotes: 1