Class

UNLocationNotificationTrigger

A trigger condition that causes a notification to be delivered when the user's device enters or exits the specified geographic region.

Declaration

@interface UNLocationNotificationTrigger : UNNotificationTrigger

Overview

Create a UNLocationNotificationTrigger object when you want to schedule the delivery of a local notification when the device enters or leaves a specific geographic region. The system limits the number of location-based triggers that may be scheduled at the same time.

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 2-kilometer radius.

Listing 1

Creating a location-based trigger

CLLocationCoordinate2D center = CLLocationCoordinate2DMake(37.335400, -122.009201);

CLCircularRegion* region = [[CLCircularRegion alloc] initWithCenter:center
                 radius:2000.0 identifier:@"Headquarters"];
region.notifyOnEntry = YES;
region.notifyOnExit = NO;

UNLocationNotificationTrigger* trigger = [UNLocationNotificationTrigger
                 triggerWithRegion:region repeats:NO];

Region-based notifications aren't always triggered immediately when the edge of the boundary is crossed. The system applies heuristics to ensure that the boundary crossing represents a deliberate event and is not the result of spurious location data. For more information about the heuristics that are applied, see Monitoring the User's Proximity to Geographic Regions.

Topics

Creating a Location Trigger

+ triggerWithRegion:repeats:

Creates a location trigger for the specified region.

Accessing the Trigger Region

region

The region used to determine when the notification is sent.

Relationships

See Also

Triggers

UNCalendarNotificationTrigger

A trigger condition that causes a notification to be delivered at a specific date and time.

UNTimeIntervalNotificationTrigger

A trigger condition that causes a notification to be delivered after the specified amount of time elapses.

UNPushNotificationTrigger

A trigger condition that indicates the notification was sent from Apple Push Notification Service (APNs).

UNNotificationTrigger

The common behavior for subclasses that trigger the delivery of a local or remote notification.