我试图将高能效与我使用CLLocationManager的,因为我的应用程序的限制:节省电池与iOS CLLocationManager
如果应用程序是在模式“A”,提供尽可能多的&作为尽可能准确的位置数据 。
如果应用程序是在模式“B”,检查在至少每10分钟一次 与“足够好”(〜500米也许)的位置数据
模式“A”和模式“B”必须两个工作,而应用程序在 背景。
由于约束3,我在plist中向UIBackgroundModes添加了'location'。 我配置我的核心位置管理器,像这样:
- (CLLocationManager *)manager {
if (_manager == nil) {
_manager = [[CLLocationManager alloc] init];
_manager.desiredAccuracy = kCLLocationAccuracyBest;
_manager.distanceFilter = kCLDistanceFilterNone;
_manager.pausesLocationUpdatesAutomatically = NO;
_manager.delegate = self;
}
return _manager;
}
我也定义像这样的枚举:
typedef NS_ENUM(NSUInteger, LocationMonitoringMode) {
LocationMonitoringModeSignificantChanges, //Mode B
LocationMonitoringModeContinuous, //Mode A
};
我用像这样:
- (void)setLocationMonitoringMode:(LocationMonitoringMode)mode {
if (mode == LocationMonitoringModeContinuous) {
[self.manager stopMonitoringSignificantLocationChanges];
[self.manager startUpdatingLocation];
} else if (mode == LocationMonitoringModeSignificantChanges) {
[self.manager stopUpdatingLocation];
[self.manager startMonitoringSignificantLocationChanges];
}
}
问题:这是'切换'使用CLLocationManager节省电池的有效方法吗?使用kCLLocationAccuracyBest
& kCLLocationAccuracy3Kilometers
(gps vs cell tower radios)显然有很大的功耗差异。但也有一个大的成本btwn,说kCLLocationAccuracyBest
& kCLLocationAccuracyNearest10Meters
?
'kCLLocationAccuracyBest'&'kCLLocationAccuracyNearest10Meters'将会花费相同。低于100米的任何东西都需要该设备为GPS芯片供电。 – progrmr 2014-12-04 00:56:28