Reputation: 570
I have an app whose core functionality revolves around the use of the user's current location. It shows objects near the user on the map. I don't create a location manager, I just use the mapview's. This works well, but now I'm trying to make sure my app alerts the user correctly of it's need for location-services. What I'm doing now is creating a new location manager in the applicationDidBecomeActive method, and attempting to start updating in order to trigger a request for permission from the user whenever the app opens or comes back from the background with location-services off like this:
- (void)applicationDidBecomeActive:(UIApplication *)application
{
CLLocationManager *manager = [[CLLocationManager alloc] init];
if([CLLocationManager locationServicesEnabled])
{
NSLog(@"yes");
}
[manager startUpdatingLocation];
}
Question 1: Is this a good way of doing it?
Question 2: Since every aspect of my app uses location-services would it be appropriate to close the app if the user selects "Don't Allow" when they are prompted that my app would like to use location-services?
Any other advise from experience with dealing with location-services and the notifications and requests to the user would be appreciated.
Upvotes: 1
Views: 932
Reputation: 21893
You can't "close" an app--Apple doesn't allow it, and there's actually no public API to "quit".
What you can do instead is throw up a view that takes over the whole screen explaining the failure to operate properly without CoreLocation permission. Maybe even with a button making CLLocationManager prompt them for permission again.
Upvotes: 1
Reputation: 33870
It is against apple's guidelines to close an app programatically and doing so will likely get it rejected.
Upvotes: 0