使用CLLocationManager
显示弹出消息
即使您没有使用该应用,也允许“AppName”访问您的位置?
有两个选项不允许和允许点击允许触发didUpdateLocations
点击不允许是它调用的委托方法吗?
答案 0 :(得分:2)
如果用户拒绝权限didFailWithError
已调用且错误类型
- (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error
{
// [manager stopUpdatingLocation];
NSLog(@"error%@",error);
switch([error code])
{
case kCLErrorNetwork: // general, network-related error
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Location Error!" message:@"Can't access your current location! Please check your network connection or that you are not in airplane mode!" delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil, nil];
[alert show];
}
break;
case kCLErrorDenied:{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Location Error!" message:@"Location Access has been denied for app name!" delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil, nil];
// alert.tag=500;
[alert show];
}
break;
default:
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Location Error!" message:@"Can't access your current location!" delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil, nil];
[alert show];
}
break;
}
}