Class

UNNotificationAction

A task to perform in response to a delivered notification.

Declaration

@interface UNNotificationAction : NSObject

Overview

Use UNNotificationAction objects to define the actions that your app can perform in response to a delivered notification. You define the actions that your app supports. For example, a meeting app might define actions for accepting or rejecting a meeting invitation. The action object itself contains the title to display in an action button and the button's appearance. After creating action objects, add them to a UNNotificationCategory object and register your categories with the system.

For information on how to define actions and categories, see Declaring Your Actionable Notification Types.

Responding to the Selection of Actions

When the user selects one of your actions in response to a notification, the system notifies the delegate of the shared UNUserNotificationCenter object. Specifically, the system calls the userNotificationCenter:didReceiveNotificationResponse:withCompletionHandler: method of your delegate object. The response object passed to your delegate includes the identifier string of the action that was selected, which you can use to perform the corresponding task.

For information on how to handle actions, see Handling Notifications and Notification-Related Actions.

Topics

Creating an Action

+ actionWithIdentifier:title:options:

Creates an action object with the specified title and options.

Getting the Action Information

identifier

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

title

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

Getting the Action Options

options

The behaviors associated with the action.

UNNotificationActionOptionNone

The action has the default behavior.

UNNotificationActionOptions

The behaviors you can apply to an action.

Relationships

Inherits From

See Also

Notification Categories and User Actions

Declaring Your Actionable Notification Types

Differentiate your notifications and add action buttons to the notification interface.

UNNotificationCategory

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

UNTextInputNotificationAction

An action that can accept user-typed text.

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software