苹果在iOS13 修改了地理位置信息授权选项,当[CLLocationManager authorizationStatus] == kCLAuthorizationStatusNotDetermined,在- (void)mapViewRequireLocationAuth:(CLLocationManager *)locationManager;实现 [locationManager requestAlwaysAuthorization].系统会显示 3 种选项:始终允许、使用应用期间、永不。而在 iOS 13 中,弹出该请求时不再提供「始终允许」选项,取而代之的是「允许一次」.所以iOS 13的用户只能授权使用应用期间使用地理位置,在手机设置里面显示的也是使用期间使用地理位置.但在- (void)amapLocationManager:(AMapLocationManager *)manager didChangeAuthorizationStatus:(CLAuthorizationStatus)status打印当前的授权权限状态却是kCLAuthorizationStatusAuthorizedAlways 始终允许的状态,出现了实际权限与代理回调的权限不一致.导致会出现定位不准,定位回调不走,状态栏不提示APP正在活跃地理位置等等一系列问题.

解决方案:

-(void)mapViewRequireLocationAuth:(CLLocationManager *)locationManager

{

    if (@available(iOS 13.0, *)) {

        [locationManager requestWhenInUseAuthorization];

    } else {

        [locationManager requestAlwaysAuthorization];

    }

}

这样设置以后在- (void)amapLocationManager:(AMapLocationManager *)manager didChangeAuthorizationStatus:(CLAuthorizationStatus)status打印当前的授权权限状态就与手机设置的状态一致,之后也暂时没遇到类似问题了.

 posted on 2020-09-11 17:45  _失控的疯子  阅读(2712)  评论(0编辑  收藏  举报