Class

UNUserNotificationCenter

The central object for managing notification-related activities for your app or app extension.

Declaration

@interface UNUserNotificationCenter : NSObject

Overview

Use the shared UNUserNotificationCenter object to manage all notification-related behaviors in your app or app extension. Specifically, use this object to:

To handle incoming notifications and notification-related actions, create an object that adopts the UNUserNotificationCenterDelegate protocol and assign it to the delegate property of this object. Always assign an object to the delegate property before performing any tasks that might interact with that delegate. It is a programmer error to assign a delegate object after calling methods that return information to the delegate.

You may use the shared user notification center object simultaneously from any of your app's threads. The object processes requests serially in the order they were initiated.

Topics

Getting the Notification Center

+ currentNotificationCenter

Returns the shared user notification center object for your app or app extension.

Receiving Notifications and Handling Actions

delegate

The object that processes incoming notifications and notification-related actions.

UNUserNotificationCenterDelegate

The interface for handling incoming notifications and notification-related actions.

Managing Settings and Authorization

- requestAuthorizationWithOptions:completionHandler:

Requests authorization to interact with the user when local and remote notifications are delivered to the user’s device.

- getNotificationSettingsWithCompletionHandler:

Requests the notification settings for this app.

supportsContentExtensions

A Boolean value indicating whether the current device supports notification content extensions.

UNAuthorizationOptions

Constants for requesting authorization to interact with the user.

Registering the Notification Categories

- setNotificationCategories:

Registers your app’s notification types and the custom actions that they support.

- getNotificationCategoriesWithCompletionHandler:

Retrieves the app’s currently registered notification categories.

Scheduling and Canceling Notification Requests

- addNotificationRequest:withCompletionHandler:

Schedules a local notification for delivery.

- getPendingNotificationRequestsWithCompletionHandler:

Returns a list of all notification requests that are scheduled and waiting to be delivered.

- removePendingNotificationRequestsWithIdentifiers:

Unschedules the specified notification requests.

- removeAllPendingNotificationRequests

Unschedules all pending notification requests.

Managing Delivered Notifications

- getDeliveredNotificationsWithCompletionHandler:

Returns a list of the app’s notifications that are still displayed in Notification Center.

- removeDeliveredNotificationsWithIdentifiers:

Removes the specified notification requests from Notification Center.

- removeAllDeliveredNotifications

Removes all of the app’s delivered notifications from Notification Center.

Handling Errors

UNErrorCode

Error constants for notifications.

UNErrorDomain

The error domain for notifications.

Relationships

Inherits From

See Also

Notification Management

UNUserNotificationCenterDelegate

The interface for handling incoming notifications and notification-related actions.

UNNotificationSettings

The object for managing notification-related settings and the authorization status of your app.