Re: MapKit location authorization
Re: MapKit location authorization
- Subject: Re: MapKit location authorization
- From: Roland King <email@hidden>
- Date: Sun, 21 Sep 2014 07:00:50 +0800
> On 20 Sep 2014, at 12:08 pm, Gerriet M. Denkmann <email@hidden> wrote:
>
>
> On 20 Sep 2014, at 01:30, Rick Mann <email@hidden> wrote:
>
>>
>> On Sep 19, 2014, at 11:06 , John Tsombakos <email@hidden> wrote:
>>
>>> You also need to add items to your Info.plist file:
>>>
>>> NSLocationAlwaysUsageDescription
>>>
>>> and/or
>>>
>>> NSLocationWhenInUseUsageDescription
>>
>> And to clarify, these are keys for a string value. That string value gets displayed as detail text in the authorization dialog. I just ran into all this myself yesterday, and it was not at all clear that this had to be done. I don't know why MKMapView can't handle all this on its own.
>
> Very good advice! This was the magic thing I was missing.
>
> I'm sure this is clearly documented somewhere (maybe at the local planning department in Alpha Centauri).
Nope - it's documented on CLLocationManager in under the relevant methods, sort of exactly where you'd expect it to be really, assuming you found the iOS docs which is easier today than it was yesterday as they appear to show in Xcode now when you ask for them instead of requiring a web search .. here's one relevant part from requestAlwaysAuthorization
"..this method runs asynchronously and prompts the user to grant permission to the app to use location services. The user prompt contains the text from the NSLocationAlwaysUsageDescription key in your app’s Info.plist file, and the presence of that key is required when calling this method. "
"For more information about the NSLocationAlwaysUsageDescription key, see Information Property List Key Reference <file:///Users/rols/Library/Developer/Shared/Documentation/DocSets/com.apple.adc.documentation.AppleiOS8.0.iOSLibrary.docset/Contents/Resources/Documents/documentation/General/Reference/InfoPlistKeyReference/Introduction/Introduction.html#//apple_ref/doc/uid/TP40009247>."
This stuff used to be optional, you could provide a helpful message saying why you wanted to use location data, but of course nobody did, so it was made mandatory in iOS8 as part of the whole transparency about what apps are doing drive. I guess there are lots of reasons why it can't just throw an exception telling the developer to add the key, but I wish mandatory things like this would do that instead of silently swallowing the calls, or return a suitable error code.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden