【发布时间】:2017-02-22 10:41:47
【问题描述】:
我一直在尝试在应用程序完全关闭时使用显着的位置更改,但它没有给出预期的结果。
我的应用程序应该检测汽车何时开始旅行。为此,我注册了重大位置变化跟踪,因此一旦发生重大变化,iOS 应启动应用程序。
在模拟器上,我模拟了高速公路行驶,它工作得很好。但是,在真实设备上,应用程序会在以非常高的速度移动 5 到 10 公里后启动。
我在商店中发现了其他成功执行此操作的应用程序,所以我想知道我的实现的哪一部分不正确。
我在 info plist 中启用了位置背景模式。这是我用来启动重要位置更新的代码:
self.significantLocationManager = [[CLLocationManager alloc] init];
self.significantLocationManager.delegate = self;
if ([self.significantLocationManager respondsToSelector:@selector(setAllowsBackgroundLocationUpdates:)]) {
self.significantLocationManager.allowsBackgroundLocationUpdates = YES;
}
[self.significantLocationManager startMonitoringSignificantLocationChanges];
编辑:我已经请求并授予我的应用“始终”使用位置服务的权限。应用程序已经在前台、后台和终止时使用了位置(但从终止状态启动需要很长时间)。
【问题讨论】:
标签: ios iphone location device