苹果审核-5. 1.5 LEGAL: PRIVACY - LOCATION SERVICES

1.被拒说明

LEGAL: PRIVACY - LOCATION SERVICES
Legal - 5.1.5

Your app uses background location services but does not clarify the purpose of its use in the location modal alert as required in the iOS Human Interface Guidelines.
We've attached screenshot(s) for your reference.

Next Steps

Please revise the NSLocationAlwaysUsageDescription value in the info.plist to specify the intended purpose of using the user's location while the app is in the background.

Resources

For additional information and instructions on configuring and presenting an alert, see the Accessing User Data section of the iOS Human Interface Guidelines and the Information Property List Key Reference.

2.被拒原因
没有描述需要定位的原因。

3.解决方法
在下图所示的位置填写需要定位的原因。

官方.png

在工程Info.plist文件中添加需要展示的信息,先添加两个字段NSLocationAlwaysUsageDescription NSLocationWhenInUseUsageDescription,如图所示:

Info.png

4.定位用户位置的代码
引入头文件#import <CoreLocation/CoreLocation.h>
添加代理CLLocationManagerDelegate

  • 创建定位管理器:
    CLLocationManager *_locationManager;
    // 初始化定位管理器
    _locationManager = [[CLLocationManager alloc] init];
    // 设置代理
    _locationManager.delegate = self;
    // 设置定位精确度到米
    _locationManager.desiredAccuracy = kCLLocationAccuracyBest;
    // 设置过滤器为无
    _locationManager.distanceFilter = kCLDistanceFilterNone;
    // 开始定位
    // 取得定位权限,有两个方法,取决于你的定位使用情况
    // 一个是requestAlwaysAuthorization,一个是requestWhenInUseAuthorization
    [_locationManager requestWhenInUseAuthorization];//这句话ios8以上版本使用。 使用期间访问位置
    [_locationManager startUpdatingLocation];
  • CLLocationManager代理
-(void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
{
    NSString * lng = [NSString stringWithFormat:@"%lf", newLocation.coordinate.longitude];//经度
    NSString * lat = [NSString stringWithFormat:@"%lf", newLocation.coordinate.latitude];//纬度
    NSTimeZone *sysZone = [NSTimeZone systemTimeZone];//系统时区
    //系统会一直更新数据,直到选择停止更新,因为我们只需要获得一次经纬度即可,所以获取之后就停止更新
    [_locationManager stopUpdatingLocation];
    NSLog(@"----lng = %@,lat = %@,syszone = %@",lng,lat,sysZone);
}
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容