-(void)judgeLocationServiceEnabled {
if ([CLLocationManager locationServicesEnabled] &&
([CLLocationManager authorizationStatus] == kCLAuthorizationStatusAuthorizedAlways
|| [CLLocationManager authorizationStatus] == kCLAuthorizationStatusAuthorizedWhenInUse)) {
//定位功能可用,開始定位
//用戶從未選擇過權限
kCLAuthorizationStatusNotDetermined = 0,
//無法使用定位服務,該狀態用戶無法改變
kCLAuthorizationStatusRestricted,
//用戶拒絕該應用使用定位服務,或者定位服務處於關閉狀態
kCLAuthorizationStatusDenied,
//一直開啟定位
kCLAuthorizationStatusAuthorizedAlways
//當使用時開啟定位
kCLAuthorizationStatusAuthorizedWhenInUse
};
}
else if ([CLLocationManager authorizationStatus] == kCLAuthorizationStatusDenied){
UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"提示" message:@"定位失敗........." preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *action = [UIAlertAction actionWithTitle:@"確定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
}];
[alert addAction:action];
[self presentViewController:alert animated:YES completion:^{
}];
}
}