This is how I'm showing Loction alert pop-up if location is not enabled.
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
LocationManager.shared.requestLocationAuthorization()
}
class LocationManager: NSObject, CLLocationManagerDelegate {
static let shared = LocationManager()
private var locationManager: CLLocationManager = CLLocationManager()
private var requestLocationAuthorizationCallback: ((CLAuthorizationStatus) -> Void)?
public func requestLocationAuthorization() {
self.locationManager.delegate = self
let currentStatus = CLLocationManager.authorizationStatus()
// Only ask authorization if it was never asked before
guard currentStatus == .notDetermined else { return }
if #available(iOS 13.4, *) {
self.requestLocationAuthorizationCallback = { status in
if status == .authorizedWhenInUse {
self.locationManager.requestAlwaysAuthorization()
}
}
self.locationManager.requestWhenInUseAuthorization()
} else {
self.locationManager.requestAlwaysAuthorization()
}
}
// MARK: - CLLocationManagerDelegate
public func locationManager(_ manager: CLLocationManager,
didChangeAuthorization status: CLAuthorizationStatus) {
self.requestLocationAuthorizationCallback?(status)
}
}
Now with this code, I get the location alert with a map within it like so..
But I want an alert that looks something like this:
How can I achieve this?