美文网首页
ios定位权限申请与提醒

ios定位权限申请与提醒

作者: LV大树 | 来源:发表于2017-11-08 14:03 被阅读1111次

//TODO: 此处可以用一个提醒框来处理
//如果没给权限:显示提醒

if ([CLLocationManager locationServicesEnabled] && ([CLLocationManager authorizationStatus] == kCLAuthorizationStatusAuthorizedWhenInUse   || [CLLocationManager authorizationStatus] == kCLAuthorizationStatusAuthorized)) {

    //定位功能可用
    shareLocationUploadManager = [DRuploaddataAndLocationManager shareManager];



}else if ([CLLocationManager authorizationStatus] ==kCLAuthorizationStatusDenied) {

    //定位不能用

    [self showAlertWithTitle:@"请求打开定位权限" Message:@"" CancelTitle:@"不定位" OthersTitles:@[@"定位"] ConfirmHandel:^(NSInteger index) {

        if (index==1) {
            NSURL * url = [NSURL URLWithString:UIApplicationOpenSettingsURLString];

            if([[UIApplication sharedApplication] canOpenURL:url]) {
                [[UIApplication sharedApplication] openURL:url];

            }

        }
    }];



}else if([CLLocationManager authorizationStatus] == kCLAuthorizationStatusNotDetermined){
    [self showAlertWithTitle:@"请求定位权限" Message:@"" CancelTitle:@"取消" OthersTitles:@[@"确定"] ConfirmHandel:^(NSInteger index) {

        if (index==1) {
            shareLocationUploadManager = [DRuploaddataAndLocationManager shareManager];

        }else{

        }

    }];
}

相关文章

网友评论

      本文标题:ios定位权限申请与提醒

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