Pravara Patil
Pravara Patil

Reputation: 513

How to handle "Cancel" button on Alert pop up for Location services

I am using location services in my application. When I run the application with location services ON, everything is perfect. But, if I turn the Location services OFF globally, and come back to the app. It gives me a pop up saying "Turn on Location services to allow to determine your location" with two buttons "Settings" and "Cancel".

If I tap on Settings, it takes me to Settings app (as expected). But If I tap on "Cancel" nothing happens. My app can't get the event and it freezes, waiting for something to happen. If I fire some other event after that, which uses current location, then it gets authorisation failed, and app becomes normal.

To handle this behaviour I want to detect the touch event on "Cancel" button. Is there any way to do that. Because I think this pop is handled by OS and not the SDK.

Correct me if I am wrong.

Upvotes: 1

Views: 1146

Answers (1)

Mute Dan
Mute Dan

Reputation: 428

This is where to detect the touch event on "Cancel" button:

- (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error{

}

Probably, Your implementation of it, causes the freezes (And not the iOS). Try and use this empty implementation just to make sure...

Upvotes: 0

Related Questions