Type Method


Creates an attachment object from the specified file and options.


+ (instancetype)attachmentWithIdentifier:(NSString *)identifier URL:(NSURL *)URL options:(NSDictionary *)options error:(NSError * _Nullable *)error;



The unique identifier of the attachment. Use this string to identify the attachment later. If you specify an empty string, this method creates a unique identifier string for you.


The URL of the file you want to attach to the notification. The URL must be a file URL and the file must be readable by the current process. This parameter must not be nil. For a list of supported file types, see Supported File Types.


A dictionary of options related to the attached file. Use the options to specify meta information about the attachment, such as the clipping rectangle to use for the resulting thumbnail.


An error object indicating whether a problem occurred. If the attachment was created successfully, this parameter is set to nil. If an error occurs, it is set to an error object containing information about why the attachment was not created. You may specify nil for this parameter if you do not want the error information.

Return Value

An attachment object containing information about the specified file or nil if the attachment could not be created.


This method verifies that the specified file is readable and that the file format is one of the supported types. When errors occur, the method provides an appropriate error object.

When you schedule a notification request containing the attachment, the attachment’s file is moved to a new location to facilitate access by the appropriate processes. After the move, the only way to access the file is using the methods of the UNUserNotificationCenter object.

See Also

Creating an Attachment


A hint about an attachment’s file type.


A Boolean value indicating whether the attachment’s thumbnail is hidden.


The clipping rectangle for a thumbnail image.


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