views:

192

answers:

2

HI,

In our application i am using corelocationframework when opening application a alert for allow and dont allow.when clicking on the allow for current location we will show current location.When clicking on the "Dont Application" we must terminate the applcation is there is any method to do that.

+2  A: 

Is this what you're after:

http://developer.apple.com/iphone/library/qa/qa2008/qa1561.html

WARNING: It is possible to quit the application by calling exit. Applications calling exit will appear to the user to have crashed, rather than performing a graceful termination and animating back to the Home screen. Such usage provides a negative experience and is strongly discouraged.

Chris Gummer
Hi chris,Thank you very much for the reply.I am clear about the terminating hte app programmatically. I am more interested in identifying whether the user chose to allow the application to make use of the Core Location or not. If the user doesn't wish to use Core Location, I'd like to terminate the application. So identifying whether or not the user allowed core location access is the key. Thanks a ton in advance.
kiri
+4  A: 

Yes, it is possible to identify whether the user allowed Core Location or not, although I want to re-iterate that terminating your app at that point is discouraged (as Chris Gummer pointed out).

The CLLocationManagerDelegate protocol has a method locationManager:didFailWithError: that will be called with an error code of kCLErrorDenied if the user does not allow Core Location to be used. You can watch for that error and have your app act accordingly.

If the user does allow Core Location to be used, locationManager:didUpdateToLocation:fromLocation: will sent to your CLLocationManagerDelegate with the new location.

hjon
Hi hjon Thank you very much for the reply
kiri
You're welcome! If it answered your question sufficiently, you should consider accepting it (the checkmark). :-)
hjon
Once again, do not do this in your application. It would be acceptable to put up an alert telling the user that functionality will be disabled until they allow Core Location to grab their position, but just killing the application is a terrible user experience.
Brad Larson