IOS 8 requestWhenInUseAuthorization no Popup

I tried to make my AppProject iOS 8 ready. I read a lot about

[_locationManager requestWhenInUseAuthorization]; 

and write to plist

 NSLocationWhenInUseUsageDescription 

So, I changed all the necessary lines of code.

It works fine, but now I again copied my project from my iOS 7 database to enable new features. But when I make changes to iOS8 Location Privacy, the popup no longer appears.

My code worked until I copied it.

 <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>NSLocationWhenInUseUsageDescription</key> <string>tolle sache </string> <key>CFBundleDevelopmentRegion</key> <string>en</string> <key>CFBundleExecutable</key> <string>${EXECUTABLE_NAME}</string> <key>CFBundleIdentifier</key> <string>fapporite.${PRODUCT_NAME:rfc1034identifier}</string> <key>CFBundleInfoDictionaryVersion</key> <string>6.0</string> <key>CFBundlePackageType</key> <string>BNDL</string> <key>CFBundleShortVersionString</key> <string>1.0</string> <key>CFBundleSignature</key> <string>????</string> <key>CFBundleVersion</key> <string>1</string> </dict> </plist> 

and here is my call

 - (instancetype)initWithCoder:(NSCoder *)coder { self = [super initWithCoder:coder]; if (self) { _UserLocation = [[CLLocation alloc]init]; _locationManager = [[CLLocationManager alloc]init]; // initializing locationManager _locationManager.delegate = self; _locationManager.desiredAccuracy = kCLLocationAccuracyBest; // setting the accuracy [_locationManager requestWhenInUseAuthorization]; // iOS 8 MUST [_locationManager startUpdatingLocation]; //requesting location updates NSLog(@"passed initwithcode"); } return self; } 

How can i fix this?

+49
objective-c privacy ios8 geolocation
Jul 20 '14 at 11:40
source share
6 answers

From the documentation

NSLocationWhenInUseUsageDescription (String - iOS) describes the reason an application typically accesses the location of users while in the foreground. Turn this key on when your application uses the location services to track the current location of users directly. This key does not support the use of location services to monitor regions or monitor users using the significant location change service. the system includes the value of this key in the warning panel displayed on the user requesting permission to use location services.

This key is required if you use the requestWhenInUseAuthorization method of the CLLocationManager class to request authorization for location services. If the key is missing when you call the requestWhenInUseAuthorization method without including this key, the system ignores your request.

This key is supported in iOS 8.0 and later. If your Info.plist file includes both this key and the NSLocationUsageDescription key, the system uses this key and ignores the NSLocationUsageDescription key.

Read about it here .

I find that the easiest way to add this key to your info.plist is to right-click on you info.plist and select

Open As-> Source Code

and then add at the end to </dict></plist>

 <key>NSLocationWhenInUseUsageDescription</key> <string></string> 

If you want, you can add text between <string></string> that describes the user why you want to use his / her location. This text will be displayed in the default text in the message.

+101
Sep 10 '14 at 12:20
source share

Try writing NSLocationWhenInUseUsageDescription in Info.plist

+18
Aug 27 '14 at 7:38
source share

iOS 8.3, Xcode 6.3.1, ARC enabled

The question has been resolved, but I have (2) notes to add from my recent participation in the CLLocationManager.

1) The following keys should be entered in your * .plist file:

enter image description here

The most commonly used keys have common more descriptive names, such as "Privacy - Description of the use of location", which is really the key "NSLocationUsageDescription".

To see the names of the "raw" keys, go to "* -Info.plist" and right-click in the "Navigator" area, where the keys are indicated, see below:

enter image description here

And you will get the following results:

enter image description here

Three keys related to this article:

enter image description here

2) Make sure you select and initialize the CLLocationManager implementation before trying to request authorization or update location.

*. h file:

 @interface SomeController : UIViewController <CLLocationManagerDelegate> @property (strong, nonatomic) CLLocationManager *locationManager; 

*. m file:

 - (IBAction)locationButton:(UIButton *)sender { if (self.locationManager == nil) { self.locationManager = [[CLLocationManager alloc] init]; self.locationManager.delegate = self; } else { nil; } if ([self.locationManager respondsToSelector:@selector(requestWhenInUseAuthorization)]) { [self.locationManager requestWhenInUseAuthorization]; } else { nil; } self.locationManager.desiredAccuracy = kCLLocationAccuracyBest; [self.locationManager startUpdatingLocation]; } 

Hope this saves you some time! Thank.

+10
May 14 '15 at
source share

Here's a little work. Make sure you add the NSLocationAlwaysUsageDescription or NSLocationWhenInUseUsageDescription keys to the main bundle of packages, and not one of your target targets!

+3
Feb 15 '16 at 20:35
source share

Was the same problem caused by the fact that I created an instance of CLLocationManager in the local var inside the method, solving it by creating the CLLocationManager property of the class.
After a while I found a solution here, but I leave it here, since this is the first result on google, I hope I save you time:

requestWhenInUseAuthorization () does not work in iOS 8 with NSLocationWhenInUseUsageDescription Key in Info.plist

+1
Nov 03 '15 at 19:14
source share

Regarding the Apple Watch:

You need to put the requestWhenInUseAuthorization key in the iPhone Info.plist , and not in the WatchKit application.

It has already bitten me twice.

0
Nov 11 '15 at 20:16
source share



All Articles