检测ios的用户是否拒绝开启默认位置的实现
原问题描述:
请问一下,检测ios的用户是否拒绝开启默认位置,能实现么?
我需要在实现检测结果,然后根据他们的选择显示不同的视图控制器。
解决方案:
假设你使用LocationManager,那么在delegate中有个方法是
[plain]
- (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error
你来检测这个error.code是什么,具体参见apple官方文档Core Location Constants Reference中CLError部分
[plain]
enum {
kCLErrorLocationUnknown = 0, // location is currently unknown, but CL will keep trying
kCLErrorDenied, // CL access has been denied (eg, user declined location use)
kCLErrorNetwork, // general, network-related error
kCLErrorHeadingFailure, // heading could not be determined
kCLErrorRegionMonitoringDenied, // Location region monitoring has been denied by the user
kCLErrorRegionMonitoringFailure, // A registered region cannot be monitored
kCLErrorRegionMonitoringSetupDelayed, // CL could not immediately initialize region monitoring
kCLErrorRegionMonitoringResponseDelayed, // While events for this fence will be delivered, delivery will not occur immediately
kCLErrorGeocodeFoundNoResult, // A geocode request yielded no result
kCLErrorGeocodeFoundPartialResult, // A geocode request yielded a partial result
kCLErrorGeocodeCanceled, // A geocode request was cancelled
kCLErrorDeferredFailed, // Deferred mode failed
kCLErrorDeferredNotUpdatingLocation, // Deferred mode failed because location updates disabled or paused
kCLErrorDeferredAccuracyTooLow, // Deferred mode not supported for the requested accuracy
kCLErrorDeferredDistanceFiltered, // Deferred mode does not support distance filters
kCLErrorDeferredCanceled, // Deferred mode request canceled a previous request
};
typedef NSInteger CLError;
补充:移动开发 , IOS ,