The uneditable content of a local or remote notification.


A UNNotificationContent object contains the data associated with a notification. When your app receives a notification, the associated UNNotificationRequest object contains an object of this type with the content that your app received. Use the content object to get the details of the notification, including the type of notification that was delivered, any custom data you stored in the userInfo dictionary before scheduling the notification, and any attachments.

Do not create instances of this class directly. For remote notifications, the contents of this object are derived from the JSON payload that your server sends to the APNS server. For local notifications, create a UNMutableNotificationContent object and configure the contents of that object instead.


Getting the Notification Data

var title: String

A short description of the reason for the alert.

var subtitle: String

A secondary description of the reason for the alert.

var body: String

The message displayed in the notification alert.

var badge: NSNumber?

The number to display as the app’s icon badge.

var sound: UNNotificationSound?

The sound to play when the notification is delivered.

var launchImageName: String

The name of the launch image to display when your app is launched in response to the notification

var userInfo: [AnyHashable : Any]

A dictionary of custom information associated with the notification.

var attachments: [UNNotificationAttachment]

An array of attachments to display with the notification.

Identifying the Content

var categoryIdentifier: String

The identifier of the app-defined category object.

var threadIdentifier: String

An app-specific identifier that you attach to related notifications.

See Also

Notification Content

class UNMutableNotificationContent

The editable content for a notification.

class UNNotificationAttachment

A media file associated with a notification.

class UNNotificationSound

A sound to be played when a notification is delivered.