Click here to Skip to main content
15,882,152 members
Articles / Mobile Apps / iPhone
Tip/Trick

Checking Location Service Permissions on iOS

Rate me:
Please Sign up or sign in to vote.
4.50/5 (2 votes)
25 Oct 2013CPOL 12.9K   2  
Check whether location service enabled for your app.

Introduction

For iOS apps, users can decide which application uses location service. Therefore you have to check location services enabled for your app. It's very easy.

Using the code

First, we have to check whether location services enabled for generally use. Second, we have to check whether location services enabled for our app.

Like this:

Objective-C
if([CLLocationManager locationServicesEnabled]){
   NSLog(@"Location Services Enabled"); 
   if([CLLocationManager authorizationStatus]==kCLAuthorizationStatusDenied){
      alert = [[UIAlertView alloc] initWithTitle:@"App Permission Denied" 
              message:@"To re-enable, please go to Settings and turn on Location Service for this app." 
              delegate:nil 
              cancelButtonTitle:@"OK" 
              otherButtonTitles:nil];
      [alert show];
   }
}

That's all!

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer NoMad Commerce
Turkey Turkey
Melih Mucuk

Software & Mobile App Developer

Visit my blog: http://melihmucuk.com

Comments and Discussions

 
-- There are no messages in this forum --