UNUserNotificationCenter
The central object for managing notification-related activities for your app or app extension.
Declaration
class UNUserNotificationCenterMentioned in
Overview
Use the shared UNUserNotificationCenter object to manage all notification-related behaviors in your app or app extension. Specifically, use this object to do the following:
Request authorization to interact with the user through alerts, sounds, and icon badges. See Asking permission to use notifications.
Declare the notification types that your app supports and the custom actions the user may perform when the system delivers those notifications. 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 the system delivers by Apple Push Notification service (APNs). See Handling notifications and notification-related actions.
Manage the already delivered notifications the system displays 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 UNUserNotificationCenterDelegate protocol and assign it to the delegate property. Always assign an object to the delegate property before performing any tasks that might interact with that 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 that the system initiates them.
Topics
Managing the notification center
Requesting authorization
Processing received notifications
Scheduling notifications
add(_:withCompletionHandler:)getPendingNotificationRequests(completionHandler:)removePendingNotificationRequests(withIdentifiers:)removeAllPendingNotificationRequests()
Removing delivered notifications
getDeliveredNotifications(completionHandler:)removeDeliveredNotifications(withIdentifiers:)removeAllDeliveredNotifications()