[英]How to show Enable Location Services Popup
class let openSettingsURLString: String
从此值创建 URL 并将其传递给open(_:options:completionHandler:)
方法以启动“设置”应用并显示应用的自定义设置(如果有)。
// Create the URL that deep links to your app's custom settings.
if let url = URL(string: UIApplication.openSettingsURLString) {
// Ask the system to open that URL.
await UIApplication.shared.open(url)
}
I guess the second pop up is not the iOS generated but custom one. You can check the location authorization status and then if location is off i.e denied or restricted in this case. So if it's denied or restricted then create a custom alert/action-sheet to show that pop up with title, subtile and button with option asking user to kindly go to setting and make location service on or just dismiss the alert/action sheet if user selects keep negative button i.e location service off button.
if CLLocationManager.locationServicesEnabled() {
print("Location service enabled")
switch CLLocationManager.authorizationStatus() {
case .notDetermined:
print("Location service not determined")
self.manager.requestWhenInUseAuthorization()
self.manager.startUpdatingLocation()
case .restricted, .denied:
// Disable location features
print("Location service DENIED")l
show that second alert/action sheet here.
case .authorizedWhenInUse, .authorizedAlways:
// Enable features that require location services here.
print("Full Access")
self.manager.startUpdatingLocation()
@unknown default:
print("unknown result")
}
} else {
print("location Services NOT Enabled")
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.