简体   繁体   中英

Handling cancel of the location services alert

I do have a situation where I need to get current location of iPhone 5 running iOS8. When the location services is off, the default location service alert open up. This alert has 'Cancel' and 'Settings' button. Please find below the screenshot of the alert. 在此处输入图片说明

I need to handle the situation when user pressed cancel on the alert. I can handle it when I override the alert. But that alert isn't working for me, as settings of that custom alert takes me to the app level location settings and not device level location settings.

Set the delegate for your CLLocationManager and implement the delegate's method - locationManager:didChangeAuthorizationStatus:

This method is called whenever the application's ability to use location services changes. Changes can occur because the user allowed or denied the use of location services for your application or for the system as a whole.

If the authorization status is already known when you call the requestWhenInUseAuthorization or requestAlwaysAuthorization method, the location manager does not report the current authorization status to this method. The location manager only reports changes to the authorization status. For example, it calls this method when the status changes from kCLAuthorizationStatusNotDetermined to kCLAuthorizationStatusAuthorizedWhenInUse.

Link to Apple doc

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM