判断应用是否允许定位当前位置
来源:互联网 发布:知乎 乾隆 书法 编辑:程序博客网 时间:2024/05/22 11:37
判断用户是否开启了定位功能:if ([CLLocationManager locationServicesEnabled] &&
([CLLocationManager authorizationStatus] == kCLAuthorizationStatusAuthorized|| [CLLocationManager authorizationStatus] == kCLAuthorizationStatusNotDetermined)) {
//定位功能可用,开始定位
_locationManger = [[CLLocationManager alloc] init];
_locationManger.delegate = self;
[_locationManger startUpdatingLocation];
} else if ([CLLocationManager authorizationStatus] == kCLAuthorizationStatusDenied) {
NSLog(@"不可用");
}
如果不可用,则提醒用户前往设置中去设置开启定位,并为用户设置跳转路径:
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"开启定位" message:@"The calendar permission was not authorized. Please enable it in Settings to continue." preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *setting = [UIAlertAction actionWithTitle:@"设置" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
NSURL *appSettings = [NSURL URLWithString:[NSString stringWithFormat:@"%@",UIApplicationOpenSettingsURLString]];
[UIApplication.sharedApplication openURL:appSettings];
}];
UIAlertAction *cancle = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
}];
[alertController addAction:setting];
[alertController addAction:cancle];
[self presentViewController:alertController animated:YES completion:nil];
- 判断应用是否允许定位当前位置
- 如何判断应用是否允许开启定位
- iOS——判断当前应用是否允许定位
- 判断手机app是否允许定位
- iOS 判断定位是否允许_跳转定位设置界面
- 判断本应用是否可以定位
- 判断是否允许使用相机
- android判断service是否允许
- 判断是否允许使用相机
- ios 判断当前应用的定位服务是否可用
- 判断是否开启定位
- 获取应用是否允许通知
- iOS检测是否开启定位、是否允许消息通知
- JavaScrip判断是否允许弹出窗口
- IOS 判断相册是否允许访问
- iOS 判断是否允许app消息推送
- 判断用户是否允许通知消息
- 判断新增行是否允许修改
- GlobalSign 域名型 SSL 证书
- 聚焦B20,看2016年互联网行业大势
- redis入门简介
- 简单的Android RecyclerView 使用小Demo
- android的消息处理机制(图+源码分析)——Looper,Handler,Message
- 判断应用是否允许定位当前位置
- resort.php
- 使用Python操作Evernote API
- python实现selenium断言和验证
- 2015年总结
- 设计模式1—创建型模式
- 跳转系统联系人页面
- img图片下面出现莫名的下边距
- IO管理一基础