Class

UNCalendarNotificationTrigger

The date and time at which to deliver a local notification.

Overview

You use a UNCalendarNotificationTrigger object to specify the temporal information for the trigger condition of a notification. Calendar triggers can fire once or they can fire multiple times.

Always use the init(dateMatching:repeats:) method to create instances of this class. Because you specify temporal information using an NSDateComponents object, you can create triggers that include only the components that matter to you. This behavior makes it easier to create repeating triggers. Listing 1 shows an example that builds a trigger to fire every morning at 8:30 by specifying only the hour and minute date components and setting the trigger to repeat.

Listing 1

Creating a trigger that repeats at a specific time

let date = DateComponents()
date.hour = 8
date.minute = 30 
let trigger = UNCalendarNotificationTrigger(dateMatching: date, repeats: true)

Topics

Creating a Calendar Trigger

init(dateMatching: DateComponents, repeats: Bool)

Creates and returns a calendar trigger from the specified date components.

Getting the Trigger Information

func nextTriggerDate()

The next date at which the trigger conditions will be met.

var dateComponents: DateComponents

The date components used to construct this object.

Relationships

See Also

Triggers

class UNTimeIntervalNotificationTrigger

The time that must expire before the delivery of a local notification.

class UNLocationNotificationTrigger

The geographic location that the user must reach to enable the delivery of a local notification.

class UNPushNotificationTrigger

An object that indicates that a notification was sent from the Apple Push Notification Service.

class UNNotificationTrigger

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