Instance Method

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.

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.

See Also

Initiating Region Monitoring

func stopMonitoring(for: CLRegion)

Stops monitoring the specified region.

var monitoredRegions: Set<CLRegion>

The set of shared regions monitored by all location manager objects.

var maximumRegionMonitoringDistance: CLLocationDistance

The largest boundary distance that can be assigned to a region.