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


A UNNotificationCategory object defines a type of notification that your executable can receive. You use category objects to implement actionable notifications—that is, notifications that have action buttons that the user can select in response to the notification. Each category object you create stores the actions and other behaviors associated with a specific type of notification.

You create category objects using the init(identifier:actions:intentIdentifiers:options:) method and register them using the singleton UNUserNotificationCenter object early in your executable’s life cycle. You can register as many category objects as you want. To take advantage of category objects, include the category’s identifier string in the payload of any notifications you create. For local notifications, you put this string in the categoryIdentifier property of the UNMutableNotificationContent object that you use to specify the notification’s content. For remote notifications, you use this string as the value of the category key in the payload dictionary.

Categories can have associated actions, which when present define custom buttons displayed along with notifications of that category. Actions are stored in the actions property. When space is not limited, the system displays up to ten actions. When space is limited, the system displays at most two actions.


Getting the Category Information

var identifier: String

The unique string assigned to the category.

var actions: [UNNotificationAction]

The actions to display when a notification of this type is presented.

var intentIdentifiers: [String]

The intents related to notifications of this category.

var options: UNNotificationCategoryOptions

Options for how to handle notifications of this type.

var hiddenPreviewsBodyPlaceholder: String

The placeholder text to display when notification previews are disabled for the app.


struct UNNotificationCategoryOptions

Constants indicating how to handle notifications associated with this category.


Inherits From

See Also

Categories and Actions

class UNNotificationAction

A task to perform in response to a delivered notification.

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.