Protocol: CLLocationManagerDelegate
Overview
The CLLocationManagerDelegate protocol defines the methods used to receive location and heading updates from a CLLocationManager object.Tells the delegate that the authorization status for the application changed.Tells the delegate that the user entered the specified region. Tells the delegate that the user left the specified region.Tells the delegate that the location manager was unable to retrieve a location value.Tells the delegate that updates will no longer be deferred.Tells the delegate that a new region is being monitored.Tells the delegate that the location manager received updated heading information.Tells the delegate that new location data is available. Tells the delegate that a region monitoring error occurred.Tells the delegate that location updates were paused. (required)Tells the delegate that the delivery of location updates has resumed. (required)Asks the delegate whether the heading calibration alert should be displayed.
Instance Method Summary (collapse)
-
- locationManager:didChangeAuthorizationStatus:
Tells the delegate that the authorization status for the application changed.
-
- locationManager:didEnterRegion:
Tells the delegate that the user entered the specified region.
-
- locationManager:didExitRegion:
Tells the delegate that the user left the specified region.
-
- locationManager:didFailWithError:
Tells the delegate that the location manager was unable to retrieve a location value.
-
- locationManager:didFinishDeferredUpdatesWithError:
Tells the delegate that updates will no longer be deferred.
-
- locationManager:didStartMonitoringForRegion:
Tells the delegate that a new region is being monitored.
-
- locationManager:didUpdateHeading:
Tells the delegate that the location manager received updated heading information.
-
- locationManager:didUpdateLocations:
Tells the delegate that new location data is available.
-
- locationManager:monitoringDidFailForRegion:withError:
Tells the delegate that a region monitoring error occurred.
-
- locationManagerDidPauseLocationUpdates:
Tells the delegate that location updates were paused.
-
- locationManagerDidResumeLocationUpdates:
Tells the delegate that the delivery of location updates has resumed.
-
- locationManagerShouldDisplayHeadingCalibration:
Asks the delegate whether the heading calibration alert should be displayed.
Instance Method Details
- (Object) locationManager(manager, didChangeAuthorizationStatus:status)
Tells the delegate that the authorization status for the application changed. This method is called whenever the application’s ability to use location services changes. Changes can occur because the user allowed or denied the use of location services for your application or for the system as a whole.
- (Object) locationManager(manager, didEnterRegion:region)
Tells the delegate that the user entered the specified region. Because regions are a shared application resource, every active location manager object delivers this message to its associated delegate. It does not matter which location manager actually registered the specified region. And if multiple location managers share a delegate object, that delegate receives the message multiple times.The region object provided may not be the same one that was registered. As a result, you should never perform pointer-level comparisons to determine equality. Instead, use the region’s identifier string to determine if your delegate should respond.
- (Object) locationManager(manager, didExitRegion:region)
Tells the delegate that the user left the specified region. Because regions are a shared application resource, every active location manager object delivers this message to its associated delegate. It does not matter which location manager actually registered the specified region. And if multiple location managers share a delegate object, that delegate receives the message multiple times.The region object provided may not be the same one that was registered. As a result, you should never perform pointer-level comparisons to determine equality. Instead, use the region’s identifier string to determine if your delegate should respond.
- (Object) locationManager(manager, didFailWithError:error)
Tells the delegate that the location manager was unable to retrieve a location value. Implementation of this method is optional. You should implement this method, however.If the location service is unable to retrieve a location right away, it reports a kCLErrorLocationUnknown error and keeps trying. In such a situation, you can simply ignore the error and wait for a new event. If the user denies your application’s use of the location service, this method reports a kCLErrorDenied error. Upon receiving such an error, you should stop the location service.If a heading could not be determined because of strong interference from nearby magnetic fields, this method returns kCLErrorHeadingFailure.
- (Object) locationManager(manager, didFinishDeferredUpdatesWithError:error)
Tells the delegate that updates will no longer be deferred. The location manager object calls this method to let you know that it has stopped deferring the delivery of location events. The manager does this when deferrals are active and when one of several actions takes place. For example, it can happen when you stop location updates altogether, when you ask the location manager to disallow deferred updates, or when a condition for deferring updates (such as exceeding a timeout or distance parameter) is met.
- (Object) locationManager(manager, didStartMonitoringForRegion:region)
Tells the delegate that a new region is being monitored.
- (Object) locationManager(manager, didUpdateHeading:newHeading)
Tells the delegate that the location manager received updated heading information. Implementation of this method is optional but expected if you start heading updates using the startUpdatingHeading method. The location manager object calls this method after you initially start the heading service. Subsequent events are delivered when the previously reported value changes by more than the value specified in the headingFilter property of the location manager object.
- (Object) locationManager(manager, didUpdateLocations:locations)
Tells the delegate that new location data is available. Implementation of this method is optional. You should implement this method, however.By the time this message is delivered to your delegate, the most recent location data is also available directly from the CLLocationManager object. The newLocation parameter may contain the data that was cached from a previous usage of the location service. You can use the timestamp property of the location object to determine how recent the location data is.
- (Object) locationManager(manager, monitoringDidFailForRegion:region, withError:error)
Tells the delegate that a region monitoring error occurred. If an error occurs while trying to monitor a given region, the location manager sends this message to its delegate. Region monitoring might fail because the region itself cannot be monitored or because there was a more general failure in configuring the region monitoring service.Although implementation of this method is optional, it is recommended that you implement it if you use region monitoring in your application.
- (Object) locationManagerDidPauseLocationUpdates(manager)
Tells the delegate that location updates were paused. (required) When the location manager detects that the device’s location is not changing, it can pause the delivery of updates in order to shut down the appropriate hardware and save power. When it does this, it calls this method to let your app know that this has happened.
- (Object) locationManagerDidResumeLocationUpdates(manager)
Tells the delegate that the delivery of location updates has resumed. (required) When location updates are paused and need to be resumed (perhaps because the user is moving again), the location manager calls this method to let your app know that it is about to begin the delivery of those updates again.
- (Boolean) locationManagerShouldDisplayHeadingCalibration(manager)
Asks the delegate whether the heading calibration alert should be displayed. Core Location may call this method in an effort to calibrate the onboard hardware used to determine heading values. Typically, Core Location calls this method at the following times:The first time heading updates are ever requestedWhen Core Location observes a significant change in magnitude or inclination of the observed magnetic fieldIf you return YES from this method, Core Location displays the heading calibration alert on top of the current window immediately. The calibration alert prompts the user to move the device in a particular pattern so that Core Location can distinguish between the Earth’s magnetic field and any local magnetic fields. The alert remains visible until calibration is complete or until you explicitly dismiss it by calling the dismissHeadingCalibrationDisplay method. In the latter case, you can use this method to set up a timer and dismiss the interface after a specified amount of time has elapsed.Note: The calibration process is able to filter out only those magnetic fields that move with the device. To calibrate a device that is near other sources of magnetic interference, the user must either move the device away from the source or move the source in conjunction with the device during the calibration process.If you return NO from this method or do not provide an implementation for it in your delegate, Core Location does not display the heading calibration alert. Even if the alert is not displayed, calibration can still occur naturally when any interfering magnetic fields move away from the device. However, if the device is unable to calibrate itself for any reason, the value in the headingAccuracy property of any subsequent events will reflect the uncalibrated readings.