請問一下,檢測ios的用戶是否拒絕開啟默認位置,能實現麼?
我需要在實現檢測結果,然後根據他們的選擇顯示不同的視圖控制器。
請賜教,謝謝。
假設你使用LocationManager,那麼在delegate中有個方法是
- (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error
你來檢測這個error.code是什麼,具體參見apple官方文檔Core Location Constants Reference中CLError部分
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;