An object that presents a custom interface for a delivered local or remote notification.
- iOS 10.0+
UNNotification protocol provides the entry point for a notification content app extension, which displays a custom interface for your app’s notifications. You adopt this protocol in the custom
UIView subclass that you use to present your interface. You create this type of extension to improve the way your notifications are presented, possibly by adding custom colors and branding, or by incorporating media and other dynamic content into your notification interface.
To define a notification content app extension, add a Notification Content extension target to the Xcode project containing your app. The default Xcode template contains a source file and storyboard for your view controller. The
Info file of the extension comes mostly configured. Specifically, the
NSExtension key is set to the value
com, and the
NSExtension key is set to the name of the project’s storyboard file. However, the
NSExtension key contains a dictionary of additional keys and values, which are listed in Table 1.
A string or an array of strings. Each string contains the identifier of a category declared by the app using the
A floating-point number that represents the initial size of your view controller’s view expressed as a ratio of its height to its width. The system uses this value to set the initial size of the view controller while your extension is loading. For example, a value of 0.5 results in a view controller whose height is half its width. You can change the size of your view controller after your extension loads.
A Boolean. When set to
A Boolean. When set to
If the notification category includes custom actions, the system automatically adds action buttons to your notification interface; don't create those buttons yourself. If your view controller implements the optional
did method, the system calls that method to respond to any selected actions. If your view controller doesn't implement that method, the system delivers the selected action to your app for handling.
The system prevents the delivery of touch events to your view controller while it is onscreen. Do not install gesture recognizers or rely on touch events in your interface.
For information about how to implement your notification content app extension, see Customizing the Appearance of Notifications.