如何在设置中添加定位服务的应用说明

How to add app explanation for location service in settings

我想在如下图的设置中添加位置服务使用的应用说明。有谁知道如何做到这一点?谢谢!

您可以在 Xcode 项目的 Info.plist 中添加说明。

<key>NSLocationAlwaysUsageDescription</key>
<string>The applicaiton requires location services to workss</string>

见下图

查看下面的结果

您可以在info.plist

中添加代码
<key>NSLocationAlwaysUsageDescription</key>
<string>This application requires location services to work</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string>This application requires location services to work</string>

同时检查定位服务权限。

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];
            }
        }

@Rurouni 的回答很完美

Xcode8 中的一些更新。他们在 plist 中为我们提供了隐私列表。

从中我们可以添加:

Privacy - Location Usage Description

<key>NSLocationUsageDescription</key>
<string>This application will use location service for user location sharing.</string>