在 iPhone 中从“隐私”->“位置服务”->“关闭”中禁用位置
location disabled from Privacy->Location Services -> off in iPhone
如果通过“隐私”->“定位服务”->“关闭”禁用位置,如何添加自定义消息。我正在使用 iPhone11 并收到有关在禁用时添加有关应用程序的描述的苹果问题。请提出建议。
您可以在 locationManager class.
中执行类似的操作
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() returns false,您可以向用户显示警报。
如果通过“隐私”->“定位服务”->“关闭”禁用位置,如何添加自定义消息。我正在使用 iPhone11 并收到有关在禁用时添加有关应用程序的描述的苹果问题。请提出建议。
您可以在 locationManager class.
中执行类似的操作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() returns false,您可以向用户显示警报。