我不确定这是一个错误还是某种配置问题但是(但是我把每个选项放在info.plist中,locationManager.allowsBackgroundLocationUpdates = true以及我在网上发现的所有其他提示仍然存在问题)
locationManager(manager:CLLocationManager,didUpdateLocations locations:[CLLocation]){}
在后台(应用程序关闭)的某些(随机)时间后停止更新位置 . 在iphone 4s ios 8.4上,此问题不存在 .
也许还有其他人解决了这个问题?谢谢
3 回答
我有同样的问题 . 我找到解决这个问题的方法是去
settings
- >privacy
- >location services
- >找到你的应用 - >allow location access
- >切换到never
- >回到location services
- >然后allow location access
再次打开你的服务 . 但有时只能工作 .另外,据我所知(可能我很担心 . )如果准确度不够你所设定的 . 位置更新不会被激活 .
我解决了它每3分钟重新启动一次位置管理器:
在你的委托方法(在我的情况下
locationDidUpdateToLocation
)中添加类似的东西还要确保
Info.plist
中有两个键(NSLocationAlwaysUsageDescription
和NSLocationWhenInUseUsageDescription
)最后,请务必在位置管理器上设置这些变量:
pausesLocationUpdatesAutomatically = false
和
此外,您还可以使用重要的更改位置服务,使用此服务,即使您暂停,iOS也会唤醒您的应用
寻找:startMonitoringSignificantLocationChanges:https://developer.apple.com/library/mac/documentation/CoreLocation/Reference/CLLocationManager_Class/index.html#//apple_ref/occ/instm/CLLocationManager/stopMonitoringSignificantLocationChanges