How iOS 12 Handles Quick Reply Notifications
Apple's iOS 12 streamlines user communication by enabling interactive notification buttons that allow users to respond to messages directly from lock screens, banners, and the Notification Center. By leveraging the UserNotifications framework, the operating system renders inline text input fields and action buttons that process responses in the background, eliminating the need to launch the host application.
The
Developer Implementation:
UNTextInputNotificationAction
Interactive replies in iOS 12 rely on the
UserNotifications framework. To implement a quick reply,
developers register a specific action using the
UNTextInputNotificationAction class rather than a standard
UNNotificationAction.
When defining the action, developers configure:
- Identifier: A unique string used by the system to identify the reply action when triggered.
- Title: The label displayed on the button (e.g., "Reply").
- Options: Flags such as
.authenticationRequired(requiring device unlock before replying) or.destructive. - Text Input Attributes: Custom button titles (like "Send") and placeholder text inside the text field to guide the user.
These actions are bundled into a UNNotificationCategory
and registered with the device's UNUserNotificationCenter.
Incoming push or local notification payloads contain a matching
category identifier, instructing iOS 12 to attach the quick
reply interface to that specific alert.
User Interaction and Interface Delivery
When a notification arrives on iOS 12, users access the quick reply interface depending on their device hardware:
- 3D Touch / Haptic Touch: A firm press or long press on the notification banner or lock screen item expands the notification.
- Swipe Gestures: On non-3D Touch devices, swiping left on the notification reveals a "View" option, which expands the card.
Once expanded, tapping the quick reply button dynamically presents the software keyboard and an inline text entry field directly within the expanded notification interface. The user types their response and taps "Send" without interrupting their current task or navigating away from their active screen.
Background Processing via the Delegate
After the user sends their reply, iOS 12 manages the response asynchronously:
- The system wakes the app in the background and calls the
userNotificationCenter(_:didReceive:withCompletionHandler:)method on the app'sUNUserNotificationCenterDelegate. - The response object is cast to
UNTextInputNotificationResponseto extract the user's typed string via theuserTextproperty. - The application executes the network request to send the reply to its servers.
- The app calls the provided completion handler once the task is finished, signaling the operating system to safely suspend the app again.
Security and Privacy Controls
iOS 12 enforces privacy controls over interactive replies. By
default, developers can specify whether a quick reply requires device
authentication. If .authenticationRequired is set, or if
the user has disabled lock screen previews in their system settings, iOS
12 prompts for Face ID, Touch ID, or a passcode before exposing the text
input interface, preventing unauthorized users from replying from a
locked device.