Implementing Notification Content Extension for iOS
Notification Content Extension displays when user long-presses a notification (3D Touch / Haptic Touch) or expands it in Notification Center. Instead of the standard preview, the system shows a custom UIViewController that you define. Action buttons remain — they're added through UNNotificationCategory.
What Can Be Implemented
Interactive preview of an order with a map and delivery address right in the notification. An incoming message card with sender's avatar and full text. A match notification with live score that updates through UNUserNotificationCenter.current().getDeliveredNotifications(). Quick reply form without opening the app.
This doesn't require the user to open the app — everything happens in the system UI.
How It Works
Content Extension — a separate target with NSExtensionPrincipalClass inherited from UIViewController, implementing UNNotificationContentExtension. The didReceive(_ notification:) method receives UNNotification and should populate UI with payload data.
In the Extension's Info.plist, we set UNNotificationExtensionCategory — a string matching the identifier of UNNotificationCategory in the main app. Only notifications with this category will show custom UI.
class NotificationViewController: UIViewController, UNNotificationContentExtension {
@IBOutlet weak var titleLabel: UILabel!
@IBOutlet weak var bodyLabel: UILabel!
func didReceive(_ notification: UNNotification) {
let content = notification.request.content
titleLabel.text = content.title
bodyLabel.text = content.body
// parse content.userInfo for additional data
}
func didReceive(_ response: UNNotificationResponse,
completionHandler completion: @escaping (UNNotificationContentExtensionResponseOption) -> Void) {
// handle action buttons tap
completion(.dismissAndForwardAction)
}
}
Custom size. Custom UI height is set in Info.plist through UNNotificationExtensionInitialContentSizeRatio (height to width ratio) — for example, 0.6 for a card. If dynamic height is needed, change preferredContentSize in code.
Media. If Notification Service Extension downloaded an attachment, it's available through notification.request.content.attachments. Content Extension can display this image in a custom UIImageView instead of the system preview.
Limitations
Extension doesn't have network access while displaying — this is not a bug, it's a sandbox limitation. Data must come in payload (up to 4KB for APNs) or through attachment (downloaded beforehand by Service Extension).
Interactive elements (UIButton, UITextField) are supported, but taps are handled through didReceive(_:completionHandler:) — not through regular IBAction. This is non-obvious and breaks classic UIKit on the first project.
What's Included in the Work
- Creating Notification Content Extension target
- Custom UI for expanded notification (XIB or programmatic)
- Registering
UNNotificationCategorywith action buttons in main app - Handling action responses and forwarding control to app
- App Groups for accessing shared data
- Testing through Xcode Simulator (Notification Content Extension works in simulator, unlike Service Extension)
Timeframe
Basic custom UI for one notification type: 1–2 days. With multiple categories, interactive elements, and Service Extension integration: 2–3 days. Cost is calculated individually.







