Triggers a notification at the specified date and time.


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)


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.