Class

UNNotificationCategory

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

Overview

A UNNotificationCategory object defines a type of notification that your executable can receive. You create category objects to define your app's 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. Register your category objects using the setNotificationCategories(_:) method of UNUserNotificationCenter. You can register as many category objects as you want.

To apply category objects to your notifications, include the category’s identifier string in the payload of any notifications you create. For local notifications, put this string in the categoryIdentifier property of the UNMutableNotificationContent object that you use to specify the notification’s content. For remote notifications, use this string as the value of the category key in the aps dictionary of your payload.

Categories can have associated actions, which define custom buttons to display for notifications of that category. When space is unlimited, the system displays up to 10 actions. When space is limited, the system displays at most two actions.

Topics

Creating a Notification Category

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 hiddenPreviewsBodyPlaceholder: String

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

var categorySummaryFormat: String

A format string for the summary description used when the system groups the category’s notifications.

Getting the Category Options

var options: UNNotificationCategoryOptions

Options for how to handle notifications of this type.

struct UNNotificationCategoryOptions

Constants indicating how to handle notifications associated with this category.

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.

class UNNotificationAction

A task to perform in response to a delivered notification.

class UNTextInputNotificationAction

An action that can accept user-typed text.