It is not proposed to enable location services in the application

UPDATE: THIS IS NOT A DUPLICATE. I have already added the necessary key to info.plist, as indicated in my original question, and the problem remains. I tried all three keys in different combinations.

Before anyone gets upset, I read a lot of posts about Apple Dev forums and stack overflows and cannot understand why my application refuses to offer the user permission to use In In Use.

I added the following key to my Info.plist file with the accompanying String value:

 NSLocationWhenInUseUsageDescription 

Then I wrote (in both Swift and Obj-C) code that should call the user:

 @property CLLocationManager *location; ... @synthesize location; ... location = [[CLLocationManager alloc] init]; location.delegate = self; location.desiredAccuracy = kCLLocationAccuracyBest; location.distanceFilter = kCLDistanceFilterNone; [location requestWhenInUseAuthorization]; [location startUpdatingLocation]; I'm using the following CLLocationManagerDelegate methods. - (void) locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations - (void) locationManager:(CLLocationManager *)manager didChangeAuthorizationStatus:(CLAuthorizationStatus)status 

This was mostly copied directly from the Apple LocateMe sample code.

No matter what different sequences or minor changes I try, the application never asks for permission. I used the switch statement to determine the status of [CLLocationManager authorizationStatus] , but I constantly get the " [CLLocationManager authorizationStatus] " response.

 if ([CLLocationManager locationServicesEnabled]) { switch ([CLLocationManager authorizationStatus]) { case kCLAuthorizationStatusAuthorizedAlways: NSLog(@"Always Authorized"); break; case kCLAuthorizationStatusDenied: NSLog(@"Denied"); break; case kCLAuthorizationStatusAuthorizedWhenInUse: NSLog(@"Authorized in Use"); break; case kCLAuthorizationStatusNotDetermined: NSLog(@"Not Determined"); break; case kCLAuthorizationStatusRestricted: NSLog(@"Restricted"); break; } } 

Any help would be greatly appreciated. I am running Xcode 6.2 (6C101) with the physical device iOS 8.1.2 and iOS 8.2 (12D5452a) for testing.

+7
ios objective-c cllocationmanager cllocation
source share
5 answers

Here are a lot of useful comparisons: http://nevan.net/2014/09/core-location-manager-changes-in-ios-8/

Also, a stupid question: you mix _location and self.location but don't show your property / synthesis code. Are you sure you are working on the same facility?

+1
source share

I encountered the same problem, after I made my way for two days, it turned out that the application did not read from the info.plist file, which was included in the project navigator panel, because it was localized in another language and the base internationalization, that is, there will be 3 info.plist files in Finder:

1- under the folder "Tests"

2- in the base.lproj folder

3- under ar.lprj (ar refers to the Arabic language).

the project reads from the base.lproj version, which is not included inside the package in the project navigator panel.

I did what I took a backup of the plist file that I want (number 2 above) and deleted the localization in the info.plist file that is inside the project navigator and selected deletion from the disk to completely delete it, then I took backup and placed it at the root of the project in Finder and imported it back into Xcode, and now the project is read from the new info.plist file, and the NSLocationWhenInUseUsageDescription key triggers a user authorization notification when the application starts.

hope this helps.

+2
source share

I found that in your info.plst file you cannot use the Privacy key - Location Usage Description, you must have a key named NSLocationWhenInUseUsageDescription and value. I managed to get your code to work by adding this key to my info.plist

enter image description here

 #import <MapKit/MapKit.h> @interface ViewController () @property CLLocationManager * location; @end @implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; _location = [[CLLocationManager alloc] init]; self.location.delegate = self; self.location.desiredAccuracy = kCLLocationAccuracyBest; self.location.distanceFilter = kCLDistanceFilterNone; [_location requestWhenInUseAuthorization]; [self.location startUpdatingLocation]; } 
+1
source share

It might be silly, but I just spent almost 2 hours doubled and tripled all the answers I could find about CLLocationManager permissions.

I felt stupid when I finally realized that I have 2 info.plist files and I used the wrong one!

You can check your project build settings - the value Info.plist File is indicated there.

I just want to leave it here for future readers.

0
source share

If you change the location settings on your iPhone simulator, this may result in the invitation not appearing. For example, if you have already set access permissions through Allow Locations to access the iOS tooltip and made a decision, this will be saved in the privacy settings for the iPhone simulator, and therefore subsequent calls to locationManager.requestAlwaysAuthorization() or locationManager.requestWhenInUseAuthorization() will not display the iOS hint because you have already defined your Privacy → Location Settings for your application.

To clear the settings for the iPhone simulator: "iOS Simulator" -> "Reset Content and Settings..."

I also made the Clean build in Xcode and at some point started and restarted the iPhone simulator, I could be mistaken that this part has any help ...

0
source share

All Articles