这是iOS后台位置更新的错误吗?
我创建了一个在后台使用位置更新的应用程序。当它进入后台时,我会启动一个后台任务,即每30秒调用startUpdatingLocation的计时器,startUpdatingLocation之后调用StopUpdateLocation的另一个计时器。我写了一个日志工具,在后台记录应用程序信息。我知道当CLLocationManager startUpdatingLocation(我说得对吗?)时,无论应用程序在后台还是前台,app.backgroundTimeRemaining都是一样的,但当CLLocationManager停止更新位置时,它将被重置为180秒。我使用的是iPhone5s,iOS 8.3这是iOS后台位置更新的错误吗?,ios,objective-c,background,location,Ios,Objective C,Background,Location,我创建了一个在后台使用位置更新的应用程序。当它进入后台时,我会启动一个后台任务,即每30秒调用startUpdatingLocation的计时器,startUpdatingLocation之后调用StopUpdateLocation的另一个计时器。我写了一个日志工具,在后台记录应用程序信息。我知道当CLLocationManager startUpdatingLocation(我说得对吗?)时,无论应用程序在后台还是前台,app.backgroundTimeRemaining都是一样的,但当CL
-(void) locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations {
WWLOG(@"locationManager didUpdateLocations");
[LogTool writeContentToFile:@"locationManager didUpdateLocations"];
UIApplication *app = [UIApplication sharedApplication];
[LogTool writeContentToFile:[NSString stringWithFormat:@"backGroundRemainingTime:(%f)",app.backgroundTimeRemaining]];
}
这个应用在后台运行了好几个小时,但突然间app.backgroundTimeRemaining变为大约160秒。这是一个bug吗?
这是记录的一部分
2015-12-10 00:00:05位置经理更新位置
2015-12-10 00:00:05背景剩余时间:(17976931348623157081452742371704356798070567525844499659891747680315726078089563276687817154045895351438246423432132688946418227684675467035516986049910576551282076245490038932894407585845513394445832369032229816580593323348274792626274747472316873817718091929988882500261848368.000000)
2015-12-10 00:00:05位置经理更新位置
2015-12-10 00:00:05背景剩余时间:(17976931348623157081452742371704356798070567525844499659891747680315726078089563276687817154045895351438246423432132688946418227684675467035516986049910576551282076245490038932894407585845513394445832369032229816580593323348274792626274747472316873817718091929988882500261848368.000000)
2015-12-10 00:00:05位置经理更新位置
2015-12-10 00:00:05背景剩余时间:(17976931348623157081452742371704356798070567525844499659891747680315726078089563276687817154045895351438246423432132688946418227684675467035516986049910576551282076245490038932894407585845513394445832369032229816580593323348274792626274747472316873817718091929988882500261848368.000000)
2015-12-10 00:00:05位置经理更新位置
2015-12-10 00:00:05背景剩余时间:(17976931348623157081452742371704356798070567525844499659891747680315726078089563276687817154045895351438246423432132688946418227684675467035516986049910576551282076245490038932894407585845513394445832369032229816580593323348274792626274747472316873817718091929988882500261848368.000000)
2015-12-10 00:00:05位置经理更新位置
2015-12-10 00:00:05背景剩余时间:(17976931348623157081452742371704356798070567525844499659891747680315726078089563276687817154045895351438246423432132688946418227684675467035516986049910576551282076245490038932894407585845513394445832369032229816580593323348274792626274747472316873817718091929988882500261848368.000000)
2015-12-10 00:00:05位置经理更新位置
2015-12-10 00:00:05背景剩余时间:(17976931348623157081452742371704356798070567525844499659891747680315726078089563276687817154045895351438246423432132688946418227684675467035516986049910576551282076245490038932894407585845513394445832369032229816580593323348274792626274747472316873817718091929988882500261848368.000000)
进展顺利,然后…
2015-12-10 04:44:39位置经理更新位置
2015-12-10 04:44:39背景剩余时间:(17976931348623157081452742371704356798070567525844499659891747680315726078089563276687817154045895351438246423432132688946418227684675467035516986049910576551282076245490038932894407585845513394445832369032229816580593323348274792626274747472316873817718091929988882500261848368.000000)
2015-12-10 04:44:40位置经理更新位置
2015-12-10 04:44:40背景剩余时间:(179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.000000)
2015-12-10 04:44:41时间:2015-12-10 04:44:36会话ID:3C95D7CC-E9D3-4B58-BCC2-384CB3EE5A47 lat:22548016l lon:113955506l精度:5000l
2015-12-10 04:45:01位置经理更新位置
2015-12-10 04:45:01背景剩余时间:(160.940208)
2015-12-10 04:45:01位置经理更新位置
2015-12-10 04:45:01背景剩余时间:(160.771241)
2015-12-10 04:45:01位置经理更新位置
2015-12-10 04:45:01背景剩余时间:(160.730064)
2015-12-10 04:45:01位置经理更新位置
2015-12-10 04:45:01背景剩余时间:(160.702347)
2015-12-10 04:45:01位置经理更新位置
2015-12-10 04:45:01背景剩余时间:(160.678130)
2015-12-10 04:45:01位置经理更新位置
2015-12-10 04:45:01背景剩余时间:(160.546829)
2015-12-10 04:45:05位置经理更新位置
2015-12-10 04:45:05背景剩余制作时间:(157.161099)
2015-12-10 04:45:06位置经理更新位置
2015-12-10 04:45:06背景剩余时间:(156.088492)