I am trying to create an application using CoreLocation, that also has a protocol LocationProtocol with locationDidFailWithError function in it, and a separate class Location. Here's the function in Location:
//gets called when user doesn't allow his location to be accessed
func locationManager(_ manager: CLLocationManager, didFailWithError error: Error) {
self.delegate?.locationDidFailWithError(error: error)
}
The ViewModel conforms to the LocationProtocol. What I need is to show an alert with an option to go to Settings app whenever user denies access to his location in case he wants to still allow the location to be accessed. So I need to create a callback function in the ViewModel that can be used in the ViewController to show the alert. I have already created the alert with an extension of UIViewController with a function called alert().
How would I create this callback function in the ViewModel and use it in the ViewController?
Any help is appreciated.