The central object for managing notification-related activities for your app or app extension.
SDKs
- iOS 10.0+
- macOS 10.14+
- Mac Catalyst 13.0+
- tvOS 10.0+
- watchOS 3.0+
Framework
- User
Notifications
Declaration
class UNUserNotificationCenter : NSObject
Overview
Use the shared UNUser
object to manage all notification-related behaviors in your app or app extension. Specifically, use this object to:
Request authorization to interact with the user through alerts, sounds, and icon badges. (Authorization is required for all user interactions.) See Asking Permission to Use Notifications.
Declare the notification types that your app supports and the custom actions (if any) that the user may perform when those notifications are delivered. See Declaring Your Actionable Notification Types.
Schedule the delivery of notifications from your app. See Scheduling a Notification Locally from Your App.
Process the payloads from remote notifications that are delivered by Apple Push Notification service (APNs). See Handling Notifications and Notification-Related Actions.
Manage the already delivered notifications that are displayed in Notification Center. See Managing Delivered Notifications.
Handle user-selected actions associated with your custom notification types; see Handling Notifications and Notification-Related Actions.
Get the notification-related settings for your app. See Managing Settings and Authorization.
To handle incoming notifications and notification-related actions, create an object that adopts the UNUser
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.