Triggers the delivery of a notification when the user reaches the specified geographic location.


A UNLocationNotificationTrigger object causes the delivery of a notification when the device enters or leaves a specified geographic region. Use this object to specify the region information needed to trigger the notification. Location triggers can fire once or they can fire multiple times.

Apps must request access to location services and must have when-in-use permissions to use this class. To request permission to use location services, call the requestWhenInUseAuthorization() method of CLLocationManager before scheduling any location-based triggers.

Always use the init(region:repeats:) method to create instances of this class. When configuring the region, use the notifyOnEntry and notifyOnExit properties to specify whether you want notifications to be delivered on entry, on exit, or both. Listing 1 shows the creation of a trigger that fires only once when the user’s device enters a circular region with a two kilometer radius.

Listing 1

Creating a location-based trigger

let center = CLLocationCoordinate2D(latitude: 37.335400, longitude: -122.009201)
let region = CLCircularRegion(center: center, radius: 2000.0, identifier: "Headquarters")
region.notifyOnEntry = true
region.notifyOnExit = false
let trigger = UNLocationNotificationTrigger(region: region, repeats: false)

The system limits the number of location-based triggers that may be scheduled at the same time. Core Location employs heuristics to determine when a boundary crossing occurs and might delay the delivery of boundary crossing events until those heuristics are met. For more information about system limits and the criteria necessary to detect region boundary crossings, see Region Monitoring and iBeacon in Location and Maps Programming Guide.


Creating a Location Trigger

init(region: CLRegion, repeats: Bool)

Creates and returns a location trigger for the specified region.

Accessing the Trigger Region

var region: CLRegion

The region used to determine when the notification is sent.