有没有办法检查用户是否允许我的应用使用他/她的位置坐标?我想在他/她按下按钮提交一些信息之前检查一下,只有在用户允许的情况下我才会激活这个按钮。
我的应用程序使用iOS 6。
谢谢
发布于 2012-10-21 19:16:13
在CLLocationManager实例的委托中,实现
- (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error方法。如果在此方法的error参数设置为kCLErrorDenied的情况下调用此方法,则用户尚未启用位置服务。您还可以实现
- (void)locationManager:(CLLocationManager *)manager didChangeAuthorizationStatus:(CLAuthorizationStatus)status方法-当此回调方法的status参数不是kCLAuthorizationStatusDenied时,则用户已启用您的应用程序来使用其位置。
发布于 2015-08-02 22:56:00
为了方便使用iOS上的权限,我创建了一个组件。
在my Github中提供:

使用block的一个示例:
/*
User can be choose two enum type for request the location authorization:
- AuthorizeRequestTypeAlwaysAuthorization
- AuthorizeRequestTypeWhenInUseAuthorization
*/
[[IOSCheckPermissions globalInstance] checkPermissionAccessForLocation:self.locationManager
authorizeRequestType:AuthorizeRequestTypeWhenInUseAuthorization
successBlock:^{
// SUCCESS ...
} failureBlock:^{
// PERMISSION DENIED ...
}];https://stackoverflow.com/questions/12997270
复制相似问题