位置访问 - 应用程序不要求用户访问位置的权限 - iOS 11 [英] Location access - App is not asking for user permission to access location - iOS 11
问题描述
说明
应用不要求用户访问位置权限并获取状态notDetermined
完美地工作到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)
{
如果status == CLAuthorizationStatus.authorizedAlways || status == CLAuthorizationStatus.authorizedWhenInUse
{
locationManager.startUpdatingLocation()
}
}
func locationManager(_ manager:CLLocationManager,didUpdateLocations locations:[ CLLocation])
{
}
Plist截图
背景模式
我已经浏览了Apple文档并找到了解决方案问题。
Apple已经改变了一些指导方针来获取用户位置。
以下是视频链接:
和身份验证消息屏幕将如下所示:
Description
App is not asking for user permission to access location and getting state notDetermined
Working perfectly till 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 screenshot
Background Modes
I have gone through the Apple documentation and found the solution for this question.
Apple has changed few guidelines to get user location.
Here is the Video Link: Apple- What's New in Location Technologies
Full code for location access in Swift & Objective-C both
Solution:
Now we need to add three Authentication Key into Plist:
- NSLocationAlwaysAndWhenInUseUsageDescription
- NSLocationWhenInUseUsageDescription
- NSLocationAlwaysUsageDescription
Plist will look like : And Authentication message screen will look like:
这篇关于位置访问 - 应用程序不要求用户访问位置的权限 - iOS 11的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!