Class

UNNotificationSettings

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

Declaration

class UNNotificationSettings : NSObject

Overview

A UNNotificationSettings object contains the current authorization status and notification-related settings for your app. Apps must receive authorization to schedule notifications and to interact with the user. Apps that run in CarPlay must similarly receive authorization to do so. You use this object to determine what notification-related actions your app is allowed to perform. You might then use that information to enable, disable, or adjust your app's notification-related behaviors. Regardless of whether you take action, the system enforces your app's settings by preventing denied interactions from occurring.

You don't create instances of this class directly. Instead, call the getNotificationSettings(completionHandler:) method of your app’s UNUserNotificationCenter object to get the current settings.

For more information about requesting authorization for user interactions, see UNUserNotificationCenter.

Topics

Getting the Authorization Status

var authorizationStatus: UNAuthorizationStatus

The app's ability to schedule and receive local and remote notifications.

enum UNAuthorizationStatus

Constants indicating whether the app is allowed to schedule notifications.

Getting Device-Specific Settings

var notificationCenterSetting: UNNotificationSetting

The setting that indicates whether your app’s notifications are displayed in Notification Center.

var lockScreenSetting: UNNotificationSetting

The setting that indicates whether your app’s notifications appear onscreen when the device is locked.

var carPlaySetting: UNNotificationSetting

The setting that indicates whether your app’s notifications may be displayed in a CarPlay environment.

var alertSetting: UNNotificationSetting

The authorization status for displaying alerts.

var badgeSetting: UNNotificationSetting

The authorization status for badging your app’s icon.

var soundSetting: UNNotificationSetting

The authorization status for playing sounds for incoming notifications.

var criticalAlertSetting: UNNotificationSetting

The authorization status to play sounds for critical alerts.

enum UNNotificationSetting

Constants indicating the current status of a notification setting.

Getting Interface Settings

var alertStyle: UNAlertStyle

The type of alert that the app may display when the device is unlocked.

enum UNAlertStyle

Constants indicating the presentation styles for alerts.

var showPreviewsSetting: UNShowPreviewsSetting

The setting that indicates whether the app shows a preview of the notification's content.

enum UNShowPreviewsSetting

Constants indicating the style previewing a notification's content.

var providesAppNotificationSettings: Bool

A Boolean value indicating the system displays a button for in-app notification settings.

Relationships

Inherits From

See Also

Notification Management

class UNUserNotificationCenter

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

protocol UNUserNotificationCenterDelegate

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