startMonitoring(for:)
Starts monitoring the specified region.
Declaration
func startMonitoring(for region: CLRegion)Parameters
- region:
The region object that defines the boundary to monitor. This parameter must not be
nil.
Mentioned in
Discussion
You must call this method once for each region you want to monitor. If an existing region with the same identifier is already being monitored by the app, the old region is replaced by the new one. The regions you add using this method are shared by all location manager objects in your app and stored in the monitoredRegions property.
Region events are delivered to the locationManager(_:didEnterRegion:) and locationManager(_:didExitRegion:) methods of your delegate. If there is an error, the location manager calls the locationManager(_:monitoringDidFailFor:withError:) method of your delegate instead.
An app can register up to 20 regions at a time. In order to report region changes in a timely manner, the region monitoring service requires network connectivity.
In iOS 6, regions with a radius between 1 and 400 meters work better on iPhone 4S or later devices. (In iOS 5, regions with a radius between 1 and 150 meters work better on iPhone 4S and later devices.) On these devices, an app can expect to receive the appropriate region entered or region exited notification within 3 to 5 minutes on average, if not sooner.
If a compatible iPad or iPhone app calls this method when running in visionOS, the method does nothing.
See Also
Methods
stopMonitoring(for:)regionMonitoringAvailable()regionMonitoringEnabled()authorizationStatus()startMonitoring(for:desiredAccuracy:)requestState(for:)startRangingBeacons(in:)stopRangingBeacons(in:)deferredLocationUpdatesAvailable()allowDeferredLocationUpdates(untilTraveled:timeout:)disallowDeferredLocationUpdates()