<!--
{
  "availability" : [
    "iOS: 10.0.0 -",
    "iPadOS: 10.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.14.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 3.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "UserNotifications",
  "identifier" : "/documentation/UserNotifications/UNNotificationAttachment",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "User Notifications"
    ],
    "preciseIdentifier" : "c:objc(cs)UNNotificationAttachment"
  },
  "title" : "UNNotificationAttachment"
}
-->

# UNNotificationAttachment

A media file associated with a notification.

```
class UNNotificationAttachment
```

## Overview

Create a [`UNNotificationAttachment`](/documentation/UserNotifications/UNNotificationAttachment) object when you want to include audio, image, or video content together in an alert-based notification. When creating the [`UNNotificationAttachment`](/documentation/UserNotifications/UNNotificationAttachment) object, the file you specify must be on disk, and the file format must be one of the supported types.

You’re responsible for supplying attachments before the system displays your notification’s alert. For local notifications, add attachments when creating the notification’s content. For remote notifications, use a notification service app extension to download the attached files and then add them to the notification’s content before delivery.

The system validates attachments before displaying the associated notification. If you attach a file to a local notification request that’s corrupted, invalid, or of an unsupported file type, the system doesn’t schedule your request. For remote notifications, the system validates attachments after your notification service app extension finishes. Once validated, the system moves the attached files into the attachment data store so that the appropriate processes can access the files. The system copies attachments located inside an app’s bundle.

### Supported File Types

Table 1 lists the types of files you can include as an attachment and the supported file formats. The table also lists the maximum size allowed for attachments of each type. An image file may contain a static image or an animated image sequence.

Table 1. Supported attachment file types

|Attachment|Supported file types                                                                                                           |Maximum size|
|----------|-------------------------------------------------------------------------------------------------------------------------------|------------|
|Audio     |`kUTTypeAudioInterchangeFileFormat` ![](spacer) `kUTTypeWaveformAudio` ![](spacer) `kUTTypeMP3` ![](spacer) `kUTTypeMPEG4Audio`|5 MB        |
|Image     |`kUTTypeJPEG` ![](spacer) `kUTTypeGIF` ![](spacer) `kUTTypePNG`                                                                |10 MB       |
|Movie     |`kUTTypeMPEG` ![](spacer) `kUTTypeMPEG2Video` ![](spacer) `kUTTypeMPEG4` ![](spacer) `kUTTypeAVIMovie`                         |50 MB       |

When creating an attachment, you can specify optional details about how to present the thumbnail image for the image or movie. Use the [`UNNotificationAttachmentOptionsThumbnailClippingRectKey`](/documentation/UserNotifications/UNNotificationAttachmentOptionsThumbnailClippingRectKey) option to use only the specified portion of an image as a thumbnail. For animated images and movies, use the [`UNNotificationAttachmentOptionsThumbnailTimeKey`](/documentation/UserNotifications/UNNotificationAttachmentOptionsThumbnailTimeKey) option to select which frame to use for the thumbnail image.

The system limits the amount of storage space allocated for attachments for each app. To delete attachments, use the methods of the [`UNUserNotificationCenter`](/documentation/UserNotifications/UNUserNotificationCenter) class to remove the notification requests that contain those attachments.

## Topics

### Creating an Attachment

[`+  attachmentWithIdentifier:URL:options:error:`](/documentation/UserNotifications/UNNotificationAttachment/init(identifier:url:options:)-83grx)

Creates an attachment object from the specified file and options.

[`UNNotificationAttachmentOptionsTypeHintKey`](/documentation/UserNotifications/UNNotificationAttachmentOptionsTypeHintKey)

A hint about an attachment’s file type.

[`UNNotificationAttachmentOptionsThumbnailHiddenKey`](/documentation/UserNotifications/UNNotificationAttachmentOptionsThumbnailHiddenKey)

A Boolean value indicating whether the system hides the attachment’s thumbnail.

[`UNNotificationAttachmentOptionsThumbnailClippingRectKey`](/documentation/UserNotifications/UNNotificationAttachmentOptionsThumbnailClippingRectKey)

The clipping rectangle for a thumbnail image.

[`UNNotificationAttachmentOptionsThumbnailTimeKey`](/documentation/UserNotifications/UNNotificationAttachmentOptionsThumbnailTimeKey)

The frame number of an animation to use as a thumbnail image.

### Getting the Attachment Contents

[`identifier`](/documentation/UserNotifications/UNNotificationAttachment/identifier)

The unique identifier for the attachment.

[`URL`](/documentation/UserNotifications/UNNotificationAttachment/url)

The URL of the file for this attachment.

[`type`](/documentation/UserNotifications/UNNotificationAttachment/type)

The UTI type of the attachment.

## Relationships

### Conforms To

[`NSCoding`](/documentation/Foundation/NSCoding)

[`CustomDebugStringConvertible`](/documentation/Swift/CustomDebugStringConvertible)

[`Hashable`](/documentation/Swift/Hashable)

[`CustomStringConvertible`](/documentation/Swift/CustomStringConvertible)

[`NSObjectProtocol`](/documentation/ObjectiveC/NSObjectProtocol)

[`NSCopying`](/documentation/Foundation/NSCopying)

[`CVarArg`](/documentation/Swift/CVarArg)

[`Equatable`](/documentation/Swift/Equatable)

[`NSSecureCoding`](/documentation/Foundation/NSSecureCoding)

### Inherits From

[`NSObject-swift.class`](/documentation/ObjectiveC/NSObject-swift.class)

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)