Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Specify the reason for accessing the user's location information on Mac OS X

Tags:

macos

cocoa

This might be a dumb question but on iOS we can specify the reason for accessing user location by including relevant keys in the info.plist file (NSLocationWhenInUseUsageDescription, NSLocationUsageDescription or NSLocationAlwaysUsageDescription).

However, it seems that this cannot be accomplished on a Mac (at least none of those work for me).

Does anyone know how to include this information so that users know for what purpose my app wants to access their location data?

like image 375
Andriy Gordiychuk Avatar asked Oct 30 '22 22:10

Andriy Gordiychuk


1 Answers

The keys indeed are included in CoreLocation.framework, and are listed within the Cocoa Keys section of the Information Property List Key Reference:

NSLocationUsageDescription ( iOS 6.0 and later, OS X v10.9 and later )
Specifies the reason for accessing the user’s location information. See NSLocationUsageDescription for details.

NSLocationWhenInUseUsageDescription ( iOS 8.0 and later, OS X v10.10 and later )
Specifies the reason for accessing the user’s location information. See NSLocationWhenInUseUsageDescription for details.

NSLocationAlwaysUsageDescription ( iOS 8.0 and later, OS X v10.10 and later )
Specifies the reason for accessing the user’s location information. See NSLocationAlwaysUsageDescription for details.

Adding the key NSLocationUsageDescription to the Info.plist automatically gets translated into human readable (Privacy - Location Usage Description):

enter image description here

enter image description here

When launching the app I'm presented with the above dialog, which includes the description. It's unclear what exactly you've tried, although from basic testing the functionality seems to work.

like image 179
l'L'l Avatar answered Nov 15 '22 05:11

l'L'l