A task to perform in response to a delivered notification.


A UNNotificationAction object represents a task that your app can perform in response to a delivered notification. You can define custom actions for each type of notification that your app supports. The action object itself contains information about how to display that action onscreen. When the user selects that action, the system forwards the action’s identifier string to your app so that you can perform the corresponding task.

Always create instances of this class using the init(identifier:title:options:) method. After creating action objects, associate them with a UNNotificationCategory object to define your app’s notification types. A notification can display up to four actions onscreen at once, and in some cases may display only two of those actions.

Responding to the Selection of Actions

You respond to the user selection of an action using the userNotificationCenter(_:didReceive:withCompletionHandler:) method of the shared UNUserNotificationCenter object’s delegate. When the user selects an action, the system calls that method and passes it a UNNotificationResponse object that includes the identifier string of the action that the user selected. Use that identifier string to determine which action was selected and then perform whatever app-specific task is appropriate for that action.

For more information about handling actions, see UNUserNotificationCenterDelegate.


Creating an Action

init(identifier: String, title: String, options: UNNotificationActionOptions = [])

Creates an action with the specified title and options.

Getting the Action Information

var identifier: String

The unique string that your app uses to identify the action.

var title: String

The localized string to use as the title of the action.

var options: UNNotificationActionOptions

The options with which to perform the action.


struct UNNotificationActionOptions

Constants indicating behaviors to apply to the action.


Inherits From

See Also

Categories and Actions

class UNNotificationCategory

A definition of a type of notification that your app supports and the custom actions to display with it.

class UNTextInputNotificationAction

An action that can accept user-specified text.

class UNTextInputNotificationResponse

The user’s response to an actionable notification, including any custom text that the user typed or dictated.