startMonitoringSignificantLocationChanges 在后台应用时每 47 秒调用一次

startMonitoringSignificantLocationChanges called every 47 sec while application in background

startMonitoringSignificantLocationChanges 被添加到后台,委托“- (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations”在后台应用时每隔 47 sec 调用一次。 如果应用程序在同一个地方,我不想点击服务器 api 来提交位置,如果位置发生了变化,那么我想将经纬度提交给服务器。

它正在耗尽 iphone 电池。我想节省我们的应用程序发生的电池消耗。

求推荐。

您需要在初始化locationmanager的地方正确设置desiredAccuracy、distanceFilter、headingFilter(如果需要的话)。

/* 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];
}