INSearchForMessagesIntent
INSearchForMessagesIntent
INSearchForMessagesIntent Class of Intents A request to list the messages that match the specified criteria.
class INSearchForMessagesIntentOverview
Siri creates INSearchForMessagesIntent objects when the user asks to see sent or received messages. You must implement this intent to support the reading of messages by Siri. This intent object contains the values for you to match when searching the user’s messages. Users can search for messages involving a specific person, messages with specific sent or received dates, or messages containing specific terms. When performing the search, use only the provided parameters, and ignore any that have no values.
To handle this intent, the handler object in your Intents extension must adopt the INSearchForMessagesIntentHandling protocol. Your handler confirms the request and creates an INSearchForMessagesIntentResponse object with the results of the search. For successful searches, Siri offers the user a way to launch your app and see the results.
Important: To implement support for this intent fully, you must also implement support for the `
doc://com.apple.sirikit/documentation/Intents/INSetMessageAttributeIntentclass. After reading messages that your search returns, Siri marks them as read by modifying the attributes of the messages using that intent class. For more information about supporting the set message attribute intent, seedoc://com.apple.sirikit/documentation/Intents/INSetMessageAttributeIntent`.
To allow a user wearing AirPods to automatically hear messages, you must implement both INSearchForMessagesIntent and INSendMessageIntent. Add //com.apple.documentation/documentation/UserNotifications/UNAuthorizationOptions/announcement to the options when calling //com.apple.documentation/documentation/UserNotifications/UNUserNotificationCenter/requestAuthorization(options:completionHandler:)). Finally, add //com.apple.documentation/documentation/UserNotifications/UNNotificationCategoryOptions/allowAnnouncement to the category option and INSearchForMessagesIntent to the category intent identifier.