如何添加自定义消息,如果位置禁用从隐私->位置服务->关闭。我正在使用iPhone11,并得到苹果的问题,以添加有关应用程序的描述,如果禁用也。请提个建议。
发布于 2020-02-06 17:40:39
您可以在您的locationManager类中执行类似的操作。
func checkLocationServices() {
if CLLocationManager.locationServicesEnabled() {
setupLocationManager()
checkLocationAuthorization()
} else {
// Show alert letting the user know they have to turn this on.
self.delegate?.showLocationServiceDialog(status: 2)
}
}
func checkLocationAuthorization() {
switch CLLocationManager.authorizationStatus() {
case .authorizedWhenInUse:
locationManager?.startUpdatingLocation()
break
case .denied:
//I'm sorry - I can't show location. User has not authorized it
self.delegate?.showLocationPermissionDialog(status: 0)
break
case .notDetermined:
locationManager!.requestAlwaysAuthorization()
case .restricted:
// Access to Location Services is Restricted", message: "Parental Controls or a system administrator may be limiting your access to location services. Ask them to.
self.delegate?.showLocationPermissionDialog(status: 1)
break
case .authorizedAlways:
locationManager?.startUpdatingLocation()
break
@unknown default:
print("Unknown permission status")
}
}在函数checkLocationServices()中,如果CLLocationManager.locationServicesEnabled()返回false,您可以向用户显示警报。
https://stackoverflow.com/questions/59980113
复制相似问题