美文网首页
定位权限

定位权限

作者: 林希品 | 来源:发表于2022-03-21 10:34 被阅读0次
#import <CoreLocation/CLLocationManager.h>

.h

/*
 * 判断是否打开定位
 */
+ (BOOL)determineWhetherTheAPPOpensTheLocation;

.m

#pragma mark 判断是否打开定位
+(BOOL)determineWhetherTheAPPOpensTheLocation{
    if ([CLLocationManager locationServicesEnabled] && ([CLLocationManager authorizationStatus] ==kCLAuthorizationStatusAuthorizedWhenInUse || [CLLocationManager authorizationStatus] ==kCLAuthorizationStatusNotDetermined || [CLLocationManager authorizationStatus] ==kCLAuthorizationStatusAuthorized)) {
        return YES;
    } else if ( [CLLocationManager authorizationStatus] == kCLAuthorizationStatusDenied ) {
        return NO;
    } else {
        return NO;
    }
}
if (![NSXYCToolObject determineWhetherTheAPPOpensTheLocation]) {
     UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"提示"
                                                    message:@"请到设置->隐私->定位服务中开启【学易车】定位服务,以便于距离筛选能够准确获得你的位置信息"
                                                   delegate:self 
                                          cancelButtonTitle:@"取消"
                                          otherButtonTitles:@"设置",nil];
     [alert show];
}

相关文章

网友评论

      本文标题:定位权限

      本文链接:https://www.haomeiwen.com/subject/xxwzdrtx.html