Ios 铁芯位置距离滤波器电池寿命
更改Ios 铁芯位置距离滤波器电池寿命,ios,core-location,battery,Ios,Core Location,Battery,更改距离过滤器值是否会影响电池寿命?如果是,这种影响是什么?为什么会有影响?distanceFilter属性对电池寿命没有影响或影响极小。它所做的只是将对委托的调用限制为每移动n米。如果你想用gps节省电池寿命,那么我建议只打开gps,每n秒读取一次读数,然后再次关闭,直到下一次读数。我会用定时器。如果您希望此功能也在后台工作,请执行以下步骤: 在应用程序plist文件中,将“应用程序位置更新注册”添加到所需的后台模式键 在ApplicationIdentinterBackground方法中,执
距离过滤器
值是否会影响电池寿命?如果是,这种影响是什么?为什么会有影响?distanceFilter属性对电池寿命没有影响或影响极小。它所做的只是将对委托的调用限制为每移动n米。如果你想用gps节省电池寿命,那么我建议只打开gps,每n秒读取一次读数,然后再次关闭,直到下一次读数。我会用定时器。如果您希望此功能也在后台工作,请执行以下步骤:
UIBackgroundTaskIdentifier __block bgTask;
UIApplication *application = [ UIApplication sharedApplication];
bgTask = [application beginBackgroundTaskWithExpirationHandler:^{
//Prevent from going inactive by starting location update
[[ ApplicationContext sharedInstance].coreLocationController startUpdatingLocation ];
[application endBackgroundTask:bgTask];
bgTask = UIBackgroundTaskInvalid;
}];
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
while (YES) {
if ( [[UIApplication sharedApplication] applicationState] == UIApplicationStateActive ) {
break;
} else {
//DO something in the background
}
}
});
在应用程序即将过期之前启动位置管理器,以确保其在后台继续处于活动状态。这将允许应用程序始终在后台运行,因此您可以通过打开/关闭gps间歇性地检查位置+我回答得很好!这就是我要找的!在后台更新位置!谢谢