
Usernotifications
- 225 installs
- 297 repo stars
- Updated August 4, 2026
- vabole/apple-skills
Configure iOS and macOS local and push notifications with UserNotifications, permission prompts, categories, actions, background delivery, and APNs payload handling for retention flows.
About
The usernotifications skill from vabole/apple-skills guides implementation of Apple’s UserNotifications framework for permission requests, local alerts, rich push payloads, notification actions, and delegate lifecycle handling. It helps mobile teams integrate reliable re-engagement, reminders, and transactional alerts with correct entitlements, categories, and server-side APNs coordination.
- Permission and authorization flows
- Local and remote notification scheduling
- Actionable notification categories
- APNs payload and delegate handling
- Background delivery considerations
Usernotifications by the numbers
- 225 all-time installs (skills.sh)
- +5 installs in the week ending Aug 5, 2026 (Skillselion tracking)
- Ranked #411 of 1,039 Mobile Development skills by installs in the Skillselion catalog
- Data as of Aug 5, 2026 (Skillselion catalog sync)
npx skills add https://github.com/vabole/apple-skills --skill usernotificationsAdd your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| Installs | 225 |
|---|---|
| repo stars | ★ 297 |
| Last updated | August 4, 2026 |
| Repository | vabole/apple-skills ↗ |
What it does
Configure iOS and macOS local and push notifications with UserNotifications, permission prompts, categories, actions, background delivery, and APNs payload handling for retention flows.
Files
UserNotifications Documentation
Search these docs to answer questions about notification APIs.
Return Format
Always include: 1. Summary - Answer the question concisely 2. File paths - List relevant files for full details, e.g.:
notifications-overview.mdfor notification center and triggers
Files
notifications-overview.md- Framework overview and notification typesunusernotificationcenter.md- Central notification managementunnotificationrequest.md- Creating notification requestsunmutablenotificationcontent.md- Notification content (title, body, etc.)uncalendarnotificationtrigger.md- Date/time-based triggersuntimeintervalnotificationtrigger.md- Interval-based triggers
Navigation: UserNotifications
Essentials
Notification management
Managing the notification center
- class func current() -> UNUserNotificationCenter)
- func getNotificationSettings(completionHandler: (UNNotificationSettings) -> Void))
- func setBadgeCount(Int, withCompletionHandler: (((any Error)?) -> Void)?))
Requesting authorization
- func requestAuthorization(options: UNAuthorizationOptions, completionHandler: (Bool, (any Error)?) -> Void))
- UNAuthorizationOptions
Options
- static var badge: UNAuthorizationOptions
- static var sound: UNAuthorizationOptions
- static var alert: UNAuthorizationOptions
- static var carPlay: UNAuthorizationOptions
- static var criticalAlert: UNAuthorizationOptions
- static var providesAppNotificationSettings: UNAuthorizationOptions
- static var provisional: UNAuthorizationOptions
Initializers
Deprecated
Processing received notifications
First Steps
Handling the Selection of Custom Actions
Receiving Notifications
- func userNotificationCenter(UNUserNotificationCenter, willPresent: UNNotification, withCompletionHandler: (UNNotificationPresentationOptions) -> Void))
- UNNotificationPresentationOptions
Constants
- static var badge: UNNotificationPresentationOptions
- static var banner: UNNotificationPresentationOptions
- static var list: UNNotificationPresentationOptions
- static var sound: UNNotificationPresentationOptions
- static var alert: UNNotificationPresentationOptions
Initializers
Displaying Notification Settings
Scheduling notifications
- func add(UNNotificationRequest, withCompletionHandler: (((any Error)?) -> Void)?))
- [func getPendingNotificationRequests(completionHandler: ([UNNotificationRequest]) -> Void)](/documentation/usernotifications/unusernotificationcenter/getpendingnotificationrequests(completionhandler:))
- [func removePendingNotificationRequests(withIdentifiers: [String])](/documentation/usernotifications/unusernotificationcenter/removependingnotificationrequests(withidentifiers:))
- func removeAllPendingNotificationRequests())
Removing delivered notifications
- [func getDeliveredNotifications(completionHandler: ([UNNotification]) -> Void)](/documentation/usernotifications/unusernotificationcenter/getdeliverednotifications(completionhandler:))
- [func removeDeliveredNotifications(withIdentifiers: [String])](/documentation/usernotifications/unusernotificationcenter/removedeliverednotifications(withidentifiers:))
- func removeAllDeliveredNotifications())
Managing notification categories
- func setNotificationCategories(Set<UNNotificationCategory>))
- func getNotificationCategories(completionHandler: (Set<UNNotificationCategory>) -> Void))
Handling errors
Type Properties
- static var notificationsNotAllowed: UNError.Code
- static var attachmentInvalidURL: UNError.Code
- static var attachmentUnrecognizedType: UNError.Code
- static var attachmentInvalidFileSize: UNError.Code
- static var attachmentNotInDataStore: UNError.Code
- static var attachmentMoveIntoDataStoreFailed: UNError.Code
- static var attachmentCorrupt: UNError.Code
- static var notificationInvalidNoDate: UNError.Code
- static var notificationInvalidNoContent: UNError.Code
- static var contentProvidingInvalid: UNError.Code
- static var contentProvidingObjectNotAllowed: UNError.Code
- static var badgeInputInvalid: UNError.Code
Error Information
Constants
- case notificationsNotAllowed
- case attachmentInvalidURL
- case attachmentUnrecognizedType
- case attachmentInvalidFileSize
- case attachmentNotInDataStore
- case attachmentMoveIntoDataStoreFailed
- case attachmentCorrupt
- case notificationInvalidNoDate
- case notificationInvalidNoContent
- case contentProvidingInvalid
- case contentProvidingObjectNotAllowed
Enumeration Cases
Initializers
Constants
- case notificationsNotAllowed
- case attachmentInvalidURL
- case attachmentUnrecognizedType
- case attachmentInvalidFileSize
- case attachmentNotInDataStore
- case attachmentMoveIntoDataStoreFailed
- case attachmentCorrupt
- case notificationInvalidNoDate
- case notificationInvalidNoContent
- case contentProvidingInvalid
- case contentProvidingObjectNotAllowed
Enumeration Cases
Initializers
First Steps
Handling the Selection of Custom Actions
Receiving Notifications
- func userNotificationCenter(UNUserNotificationCenter, willPresent: UNNotification, withCompletionHandler: (UNNotificationPresentationOptions) -> Void))
- UNNotificationPresentationOptions
Constants
- static var badge: UNNotificationPresentationOptions
- static var banner: UNNotificationPresentationOptions
- static var list: UNNotificationPresentationOptions
- static var sound: UNNotificationPresentationOptions
- static var alert: UNNotificationPresentationOptions
Initializers
Displaying Notification Settings
Getting the Authorization Status
Status
Initializers
Getting Device-Specific Settings
- var notificationCenterSetting: UNNotificationSetting
- var lockScreenSetting: UNNotificationSetting
- var carPlaySetting: UNNotificationSetting
- var alertSetting: UNNotificationSetting
- var badgeSetting: UNNotificationSetting
- var soundSetting: UNNotificationSetting
- var criticalAlertSetting: UNNotificationSetting
- var announcementSetting: UNNotificationSetting
- var scheduledDeliverySetting: UNNotificationSetting
- var timeSensitiveSetting: UNNotificationSetting
- UNNotificationSetting
Constants
Initializers
Getting Interface Settings
Presentation Styles
Initializers
Preview Styes
Initializers
Instance Properties
Initializers
Remote notifications
Server tasks
- Registering your app with APNs
- Generating a remote notification
- Pushing background updates to your App
- Establishing a connection to Apple Push Notification service (APNs)
Security
Device push notifications
- Sending notification requests to APNs
- Handling notification responses from APNs
- Viewing the status of push notifications using Metrics and APNs
Broadcast push notifications
- Setting up broadcast push notifications
- Sending channel management requests to APNs
- Sending broadcast push notification requests to APNs
- Handling error responses from Apple Push Notification service
Troubleshooting
- Sending push notifications using command-line tools
- Testing notifications using the Push Notification Console
Notification requests
Related Topics
Creating a Notification Request
Getting the Request Details
Initializers
Getting the Notification Details
Initializers
Push notifications in Safari
Notification content
Essentials
Initializers
Providing the primary content
Providing supplementary content
- [var attachments: [UNNotificationAttachment]](/documentation/usernotifications/unmutablenotificationcontent/attachments)
- [var userInfo: [AnyHashable : Any]](/documentation/usernotifications/unmutablenotificationcontent/userinfo)
Configuring app behavior
Integrating with the system
- var sound: UNNotificationSound?
- var interruptionLevel: UNNotificationInterruptionLevel
- UNNotificationInterruptionLevel
Enumeration Cases
Initializers
Grouping notifications
- var threadIdentifier: String
- var categoryIdentifier: String
- var summaryArgument: String
- var summaryArgumentCount: Int
Accessing the primary content
Accessing supplementary content
- [var attachments: [UNNotificationAttachment]](/documentation/usernotifications/unnotificationcontent/attachments)
- [var userInfo: [AnyHashable : Any]](/documentation/usernotifications/unnotificationcontent/userinfo)
Reading app configuration
Reading system configuration
- var sound: UNNotificationSound?
- var interruptionLevel: UNNotificationInterruptionLevel
- UNNotificationInterruptionLevel
Enumeration Cases
Initializers
Retrieving group information
- var threadIdentifier: String
- var categoryIdentifier: String
- var summaryArgument: String
- var summaryArgumentCount: Int
Updating the notification’s content
Initializers
Creating an Attachment
- [convenience init(identifier: String, url: URL, options: [AnyHashable : Any]?) throws](/documentation/usernotifications/unnotificationattachment/init(identifier:url:options:)-83grx)
- let UNNotificationAttachmentOptionsTypeHintKey: String
- let UNNotificationAttachmentOptionsThumbnailHiddenKey: String
- let UNNotificationAttachmentOptionsThumbnailClippingRectKey: String
- let UNNotificationAttachmentOptionsThumbnailTimeKey: String
Getting the Attachment Contents
Initializers
- init?(coder: NSCoder))
- [convenience init(identifier: String, URL: URL, options: [AnyHashable : Any]?) throws](/documentation/usernotifications/unnotificationattachment/init(identifier:url:options:)-7oony)
Creating Notification Sounds
Getting Critical Sounds
- class var defaultCritical: UNNotificationSound
- class func defaultCriticalSound(withAudioVolume: Float) -> Self)
- class func criticalSoundNamed(UNNotificationSoundName) -> Self)
- class func criticalSoundNamed(UNNotificationSoundName, withAudioVolume: Float) -> Self)
Type Properties
Type Methods
Initializers
Initializers
Triggers
Creating a Calendar Trigger
Getting the Trigger Information
Initializers
Creating a Time Interval Trigger
Getting the Trigger Information
Creating a Location Trigger
Accessing the Trigger Region
Configuring the Trigger’s Behavior
Initializers
Notification categories and user actions
Essentials
- [convenience init(identifier: String, actions: [UNNotificationAction], intentIdentifiers: [String], options: UNNotificationCategoryOptions)](/documentation/usernotifications/unnotificationcategory/init(identifier:actions:intentidentifiers:options:))
- [convenience init(identifier: String, actions: [UNNotificationAction], intentIdentifiers: [String], hiddenPreviewsBodyPlaceholder: String, options: UNNotificationCategoryOptions)](/documentation/usernotifications/unnotificationcategory/init(identifier:actions:intentidentifiers:hiddenpreviewsbodyplaceholder:options:))
- [convenience init(identifier: String, actions: [UNNotificationAction], intentIdentifiers: [String], hiddenPreviewsBodyPlaceholder: String?, categorySummaryFormat: String?, options: UNNotificationCategoryOptions)](/documentation/usernotifications/unnotificationcategory/init(identifier:actions:intentidentifiers:hiddenpreviewsbodyplaceholder:categorysummaryformat:options:))
Getting the Information
- var identifier: String
- [var actions: [UNNotificationAction]](/documentation/usernotifications/unnotificationcategory/actions)
- [var intentIdentifiers: [String]](/documentation/usernotifications/unnotificationcategory/intentidentifiers)
- var hiddenPreviewsBodyPlaceholder: String
- var categorySummaryFormat: String
Getting the Options
Creating an option
Customizing a category
- static var allowInCarPlay: UNNotificationCategoryOptions
- static var allowAnnouncement: UNNotificationCategoryOptions
Managing hidden preview behavior
- static var hiddenPreviewsShowTitle: UNNotificationCategoryOptions
- static var hiddenPreviewsShowSubtitle: UNNotificationCategoryOptions
Managing action handling behavior
Initializers
Essentials
- convenience init(identifier: String, title: String, options: UNNotificationActionOptions))
- convenience init(identifier: String, title: String, options: UNNotificationActionOptions, icon: UNNotificationActionIcon?))
Getting Information
Getting Options
Initializers
Constants
- static var authenticationRequired: UNNotificationActionOptions
- static var destructive: UNNotificationActionOptions
- static var foreground: UNNotificationActionOptions
Initializers
Essentials
- convenience init(identifier: String, title: String, options: UNNotificationActionOptions, textInputButtonTitle: String, textInputPlaceholder: String))
- convenience init(identifier: String, title: String, options: UNNotificationActionOptions, icon: UNNotificationActionIcon?, textInputButtonTitle: String, textInputPlaceholder: String))
Getting Information
Notification responses
Getting the Response Information
- var actionIdentifier: String
- var notification: UNNotification
- var targetScene: UIScene?
- let UNNotificationDefaultActionIdentifier: String
- let UNNotificationDismissActionIdentifier: String
Initializers
Getting the Text Response
Notification service app extension
Processing Notifications
- func didReceive(UNNotificationRequest, withContentHandler: (UNNotificationContent) -> Void))
- func serviceExtensionTimeWillExpire())
Entitlements
Sample code
- Handling Communication Notifications and Focus Status Updates
- Implementing Alert Push Notifications
- Implementing Background Push Notifications
Classes
Initializers
---
Extracted from Apple DocC JSON by apple-skills tooling. This is unofficial content. All documentation belongs to Apple Inc.
Navigation: UserNotifications
Class
UNCalendarNotificationTrigger
Available on: iOS 10.0+, iPadOS 10.0+, Mac Catalyst 13.1+, macOS 10.14+, tvOS 10.0+, visionOS 1.0+, watchOS 3.0+
A trigger condition that causes a notification the system delivers at a specific date and time.
class UNCalendarNotificationTriggerOverview
Create a UNCalendarNotificationTrigger object when you want to schedule the delivery of a local notification at the date and time you specify. You use an NSDateComponents object to specify only the time values that you want the system to use to determine the matching date and time.
Listing 1 creates a trigger that delivers its notification every morning at 8:30. The repeating behavior is achieved by specifying true for the repeats parameter when creating the trigger.
Listing 1. Creating a trigger that repeats at a specific time
Swift
var date = DateComponents()
date.hour = 8
date.minute = 30
let trigger = UNCalendarNotificationTrigger(dateMatching: date, repeats: true)Objective-C
NSDateComponents* date = [[NSDateComponents alloc] init];
date.hour = 8;
date.minute = 30;
UNCalendarNotificationTrigger* trigger = [UNCalendarNotificationTrigger
triggerWithDateMatchingComponents:date repeats:YES];Inherits From
Conforms To
- CVarArg
- CustomDebugStringConvertible
- CustomStringConvertible
- Equatable
- Hashable
- NSCoding
- NSCopying
- NSObjectProtocol
- NSSecureCoding
Creating a Calendar Trigger
- init(dateMatching:repeats:)) Creates a calendar trigger using the date components parameter.
Getting the Trigger Information
- nextTriggerDate()) The next date at which the trigger conditions are met.
- dateComponents The date components to construct this object.
Initializers
Triggers
- UNTimeIntervalNotificationTrigger A trigger condition that causes the system to deliver a notification after the amount of time you specify elapses.
- UNLocationNotificationTrigger A trigger condition that causes the system to deliver a notification when the user’s device enters or exits a geographic region you specify.
- UNPushNotificationTrigger A trigger condition that indicates Apple Push Notification Service (APNs) has sent the notification.
- UNNotificationTrigger The common behavior for subclasses that trigger the delivery of a local or remote notification.
---
Extracted from Apple DocC JSON by apple-skills tooling. This is unofficial content. All documentation belongs to Apple Inc.
Navigation: UserNotifications
Class
UNMutableNotificationContent
Available on: iOS 10.0+, iPadOS 10.0+, Mac Catalyst 13.1+, macOS 10.14+, tvOS 10.0+, visionOS 1.0+, watchOS 3.0+
The editable content for a notification.
class UNMutableNotificationContentOverview
Create a UNMutableNotificationContent object when you want to specify the payload for a local notification. Specifically, use this object to specify the title and message for an alert, the sound to play, or the value to assign to your app’s badge. You might also provide details about how the system handles the notification. For example, you can specify a custom launch image and a thread identifier for visually grouping related notifications.
After creating your content object, assign it to a UNNotificationRequest object, add a trigger condition, and schedule your notification. The trigger condition defines when the system delivers the notification to the user. Listing 1 shows the scheduling of a local notification that displays an alert and plays a sound after a delay of five seconds. Store the strings for the alert’s title and body in the app’s Localizable.strings file.
Listing 1. Creating the content for a local notification
Swift
// Configure the notification's payload.
let content = UNMutableNotificationContent()
content.title = NSString.localizedUserNotificationString(forKey: "Hello!", arguments: nil)
content.body = NSString.localizedUserNotificationString(forKey: "Hello_message_body", arguments: nil)
content.sound = UNNotificationSound.default
// Deliver the notification in five seconds.
let trigger = UNTimeIntervalNotificationTrigger(timeInterval: 5, repeats: false)
let request = UNNotificationRequest(identifier: "FiveSecond", content: content, trigger: trigger) // Schedule the notification.
let center = UNUserNotificationCenter.current()
center.add(request) { (error : Error?) in
if let theError = error {
// Handle any errors
}
}Objective-C
// Configure the notification's payload.
UNMutableNotificationContent *content = [[UNMutableNotificationContent alloc] init];
content.title = [NSString localizedUserNotificationStringForKey:@"Hello!" arguments:nil];
content.body = [NSString localizedUserNotificationStringForKey:@"Hello_message_body" arguments:nil];
content.sound = [UNNotificationSound defaultSound];
// Deliver the notification in five seconds.
UNTimeIntervalNotificationTrigger* trigger = [UNTimeIntervalNotificationTrigger
triggerWithTimeInterval:5 repeats:NO];
UNNotificationRequest* request = [UNNotificationRequest requestWithIdentifier:@"FiveSecond"
content:content trigger:trigger];
// Schedule the notification.
UNUserNotificationCenter* center = [UNUserNotificationCenter currentNotificationCenter];
[center addNotificationRequest:request];Note: Local notifications always result in user interactions, and the system ignores any interactions for which your app isn’t authorized. For information about how to request authorization for user interactions, see Asking permission to use notifications.
Localizing the Alert Strings
Localize the strings you display in a notification alert for the current user. Although you can use the NSLocalizedString macros to load strings from your app’s resource files, a better option is to specify your string using the localizedUserNotificationString(forKey:arguments:)) method of NSString. The localizedUserNotificationString(forKey:arguments:)) method delays the loading of the localized string until the system delivers the notification. If the user changes the language setting before the system delivers a notification, the system updates the alert text to the user’s current language instead of the language in use when the system scheduled the notification.
Inherits From
Conforms To
- CVarArg
- CustomDebugStringConvertible
- CustomStringConvertible
- Equatable
- Hashable
- NSCoding
- NSCopying
- NSMutableCopying
- NSObjectProtocol
- NSSecureCoding
Providing the primary content
- title The localized text that provides the notification’s primary description.
- subtitle The localized text that provides the notification’s secondary description.
- body The localized text that provides the notification’s main content.
Providing supplementary content
- attachments The visual and audio attachments to display alongside the notification’s main content.
- userInfo The custom data to associate with the notification.
Configuring app behavior
- launchImageName The name of the image or storyboard to use when your app launches because of the notification.
- badge The number that your app’s icon displays.
- targetContentIdentifier The value your app uses to determine which scene to display to handle the notification.
Integrating with the system
- sound The sound that plays when the system delivers the notification.
- interruptionLevel The notification’s importance and required delivery timing.
- UNNotificationInterruptionLevel Constants that indicate the importance and delivery timing of a notification.
- relevanceScore The score the system uses to determine if the notification is the summary’s featured notification.
- filterCriteria The criteria the system evaluates to determine if it displays the notification in the current Focus.
Grouping notifications
- threadIdentifier The identifier that groups related notifications.
- categoryIdentifier The identifier of the notification’s category.
- summaryArgument The text the system adds to the notification summary to provide additional context.
- summaryArgumentCount The number the system adds to the notification summary when the notification represents multiple items.
Notification content
- Implementing communication notifications Configure and display your app’s communication notifications by using intents.
- UNNotificationContentProviding A protocol the system uses to provide context relevant to user notifications.
- UNNotificationActionIcon An icon associated with an action.
- UNNotificationContent The uneditable content of a notification.
- UNNotificationAttachment A media file associated with a notification.
- UNNotificationSound The sound played upon delivery of a notification.
- UNNotificationSoundName A string providing the name of a sound file.
---
Extracted from Apple DocC JSON by apple-skills tooling. This is unofficial content. All documentation belongs to Apple Inc.
Navigation: UserNotifications
Class
UNNotificationRequest
Available on: iOS 10.0+, iPadOS 10.0+, Mac Catalyst 13.1+, macOS 10.14+, tvOS 10.0+, visionOS 1.0+, watchOS 3.0+
A request to schedule a local notification, which includes the content of the notification and the trigger conditions for delivery.
class UNNotificationRequestOverview
Create a UNNotificationRequest object when you want to schedule the delivery of a local notification. A notification request object contains a UNNotificationContent object with the payload and the UNNotificationTrigger object with the conditions that trigger the delivery of the notification. To schedule the delivery of your notification, pass your request object to the add(_:withCompletionHandler:)) method of the shared user notification center object.
After scheduling a request, you interact with UNNotificationRequest objects in the following ways:
- View your app’s pending notifications by calling the getPendingNotificationRequests(completionHandler:)) method of your shared user notification center object.
- When the system delivers a notification to your app, the provided UNNotification object contains a
UNNotificationRequestobject that you can inspect to get the notification details. - Use the request’s identifier to remove delivered notifications from Notification Center.
When receiving a local or remote notification, use the provided UNNotificationRequest object to fetch details about the notification.
// Create a content object with the message to convey.
let content = UNMutableNotificationContent()
content.title = "Lunch time"
content.body = "Food is cooked... let's eat!"
// Create a notification trigger for 60 seconds in the future.
let trigger = UNTimeIntervalNotificationTrigger(timeInterval: 60.0, repeats: false)
// Create the request with the content and the trigger.
let request = UNNotificationRequest(identifier: "com.example.mynotification", content: content, trigger: trigger)Inherits From
Conforms To
- CVarArg
- CustomDebugStringConvertible
- CustomStringConvertible
- Equatable
- Hashable
- NSCoding
- NSCopying
- NSObjectProtocol
- NSSecureCoding
Creating a Notification Request
- init(identifier:content:trigger:)) Creates a notification request object that you use to schedule a notification.
Getting the Request Details
- identifier The unique identifier for this notification request.
- content The content associated with the notification.
- trigger The conditions that trigger the delivery of the notification.
Initializers
Notification requests
- Scheduling a notification locally from your app Create and schedule notifications from your app when you want to get the user’s attention.
- UNNotification The data for a local or remote notification the system delivers to your app.
---
Extracted from Apple DocC JSON by apple-skills tooling. This is unofficial content. All documentation belongs to Apple Inc.
Navigation: UserNotifications
Class
UNTimeIntervalNotificationTrigger
Available on: iOS 10.0+, iPadOS 10.0+, Mac Catalyst 13.1+, macOS 10.14+, tvOS 10.0+, visionOS 1.0+, watchOS 3.0+
A trigger condition that causes the system to deliver a notification after the amount of time you specify elapses.
class UNTimeIntervalNotificationTriggerOverview
Create a UNTimeIntervalNotificationTrigger object when you want to schedule the delivery of a local notification after the number of seconds you specify elapses. You use this type of trigger to implement timers.
Listing 1 creates a trigger that delivers its notification one time after 30 minutes have elapsed.
Listing 1. Creating a trigger that fires in 30 minutes
Swift
// Fire in 30 minutes (60 seconds times 30)
let trigger = UNTimeIntervalNotificationTrigger(timeInterval: (30*60), repeats: false)Objective-C
// Fire in 30 minutes (60 seconds times 30)
UNTimeIntervalNotificationTrigger* trigger = [UNTimeIntervalNotificationTrigger
triggerWithTimeInterval:(30*60) repeats: NO];Inherits From
Conforms To
- CVarArg
- CustomDebugStringConvertible
- CustomStringConvertible
- Equatable
- Hashable
- NSCoding
- NSCopying
- NSObjectProtocol
- NSSecureCoding
Creating a Time Interval Trigger
- init(timeInterval:repeats:)) Creates a time interval trigger using the time value parameter.
Getting the Trigger Information
- nextTriggerDate()) The next date at which the trigger conditions are met.
- timeInterval The time interval to create the trigger.
Triggers
- UNCalendarNotificationTrigger A trigger condition that causes a notification the system delivers at a specific date and time.
- UNLocationNotificationTrigger A trigger condition that causes the system to deliver a notification when the user’s device enters or exits a geographic region you specify.
- UNPushNotificationTrigger A trigger condition that indicates Apple Push Notification Service (APNs) has sent the notification.
- UNNotificationTrigger The common behavior for subclasses that trigger the delivery of a local or remote notification.
---
Extracted from Apple DocC JSON by apple-skills tooling. This is unofficial content. All documentation belongs to Apple Inc.
Navigation: UserNotifications
Class
UNUserNotificationCenter
Available on: iOS 10.0+, iPadOS 10.0+, Mac Catalyst 13.1+, macOS 10.14+, tvOS 10.0+, visionOS 1.0+, watchOS 3.0+
The central object for managing notification-related activities for your app or app extension.
class UNUserNotificationCenterOverview
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.
Inherits From
Conforms To
Managing the notification center
- current()) Returns your app’s notification center.
- getNotificationSettings(completionHandler:)) Retrieves the authorization and feature-related settings for your app.
- setBadgeCount(_:withCompletionHandler:)) Updates the badge count for your app’s icon.
Requesting authorization
- requestAuthorization(options:completionHandler:)) Requests a person’s authorization to allow local and remote notifications for your app.
- UNAuthorizationOptions Options that determine the authorized features of local and remote notifications.
Processing received notifications
- delegate The notification center’s delegate.
- UNUserNotificationCenterDelegate An interface for processing incoming notifications and responding to notification actions.
- supportsContentExtensions A Boolean value that indicates whether the device supports notification content extensions.
Scheduling notifications
- add(_:withCompletionHandler:)) Schedules the delivery of a local notification.
- getPendingNotificationRequests(completionHandler:)) Fetches all of your app’s local notifications that are pending delivery.
- removePendingNotificationRequests(withIdentifiers:)) Removes your app’s local notifications that are pending and match the specified identifiers.
- removeAllPendingNotificationRequests()) Removes all of your app’s pending local notifications.
Removing delivered notifications
- getDeliveredNotifications(completionHandler:)) Fetches all of your app’s delivered notifications that are still present in Notification Center.
- removeDeliveredNotifications(withIdentifiers:)) Removes your app’s notifications from Notification Center that match the specified identifiers.
- removeAllDeliveredNotifications()) Removes all of your app’s delivered notifications from Notification Center.
Managing notification categories
- setNotificationCategories(_:)) Registers the notification categories that your app supports.
- getNotificationCategories(completionHandler:)) Fetches your app’s registered notification categories.
Handling errors
- UNError An object that represents a notification error.
- UNError.Code Constants that identify notification errors.
- UNErrorDomain The error domain for notifications.
Notification management
- UNUserNotificationCenterDelegate An interface for processing incoming notifications and responding to notification actions.
- UNNotificationSettings The object for managing notification-related settings and the authorization status of your app.
---
Extracted from Apple DocC JSON by apple-skills tooling. This is unofficial content. All documentation belongs to Apple Inc.