作者:书友44802979 | 来源:互联网 | 2023-01-17 14:42
描述
应用程序不要求用户访问位置和获取状态未确定的权限
完美地工作到iOS-10
var locationManager : CLLocationManager!
func getLocationDetails()
{
locationManager.delegate = self
locationManager.desiredAccuracy = kCLLocationAccuracyBest
locationManager.requestAlwaysAuthorization()
locationManager.allowsBackgroundLocatiOnUpdates= true
locationManager.startUpdatingLocation()
}
func locationManager(_ manager: CLLocationManager, didChangeAuthorization status: CLAuthorizationStatus)
{
if status == CLAuthorizationStatus.authorizedAlways || status == CLAuthorizationStatus.authorizedWhenInUse
{
locationManager.startUpdatingLocation()
}
}
func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation])
{
}
Plist截图
背景模式
1> Alok..:
我已经浏览了Apple文档并找到了这个问题的解决方案.
Apple已经改变了一些指导方针来获取用户位置.
以下是视频链接:Apple-位置技术的新功能
Swift和Objective-C中的位置访问的完整代码
解:
现在我们需要在Plist中添加三个身份验证密钥:
NSLocationAlwaysAndWhenInUseUsageDescription
NSLocationWhenInUseUsageDescription
NSLocationAlwaysUsageDescription
Plist看起来像:
身份验证消息屏幕将如下所示:
位置访问的完整代码