3分钟后iOS 9位置更新后台任务

ahe*_*ick 9 xcode background-process cllocationmanager ios

我一直在深入研究这个使用基本计时器检查位置更新的代码.然后我将它发送到服务器的lat/lng.

http://mobileoop.com/background-location-update-programming-for-ios-7 https://github.com/voyage11/Location

当插入并通过XCode连接时,它运行良好,但是当我拔下并移动设备时,操作系统似乎总是在3分钟后完全杀死后台线程.因此,如果我将计时器设置为每30秒运行一次,我将获得~6次更新,直到我将应用程序带到前台.

我已经读过最大后台执行时间是3分钟,但是我看到这个代码在1分钟后重置了后台任务,所以我不知道为什么我会看到这个.

必须有一些解决方法.我能在这做什么吗?

编辑:这帮助我:在iOS9中的CLLocationManager中的allowsBackgroundLocationUpdates

Nil*_*esh 6

SE:

if ([self.locationManager respondsToSelector:@selector(setAllowsBackgroundLocationUpdates:)]) {
    [self.locationManager setAllowsBackgroundLocationUpdates:YES];
}
Run Code Online (Sandbox Code Playgroud)

这是后台位置跟踪所必需的.