didReceive(_:completionHandler:)
Handles a notification action selected by the user.
Declaration
optional func didReceive(_ response: UNNotificationResponse, completionHandler completion: @escaping @Sendable (UNNotificationContentExtensionResponseOption) -> Void)optional func didReceive(_ response: UNNotificationResponse) async -> UNNotificationContentExtensionResponseOptionParameters
- response:
The response object that identifies the user-selected action. Use this object to get information about the notification and the user’s response.
- completion:
The block to execute when you are finished performing the action. You must call this block at some point during your implementation. The block has no return value and takes the following parameter:
dismissThe response you want to take for the notification. For a list of possible options, see Unnotificationcontentextensionresponseoption.
Discussion
Implement this method when you want your view controller to handle actions selected by the user. Use your implementation to perform the associated task and then execute the completion block. If you implement this method, you must handle all actions defined in all categories managed by your Notification Content app extension. If you don’t implement this method, the system notifies your app when the user selects an action.