A representation of the message you use as context for suggested actions.
Create a `SuggestedActionsMessage` from your app's data model for a message, then pass
it to ``SuggestedActionsView/init(message:previousMessages:)`` or
``SuggestedActionsView/generate(message:previousMessages:)``.
The `id` you pass to the create a `SuggestedActionsMessage` must be unique for each message and
stable across app launches. Creating stable identifiers lets the framework match
messages against previously cached suggested actions.
> Note: To use the Suggested Actions framework, add the
<doc://com.apple.documentation/documentation/bundleresources/entitlements/com.apple.developer.suggested-actions>
entitlement to your app target.
Members (2)
get · iOS 27.0+
previousMessagesLimit
TypeScript
static get previousMessagesLimit(): number
Swift declaration
static var previousMessagesLimit: Int { get }
The maximum number of previous messages that contribute to generating suggested actions.
When you pass an array of ``SuggestedActionsMessage`` values to the
`previousMessages` parameter of
``SuggestedActionsView/init(message:previousMessages:)`` or
``SuggestedActionsView/generate(message:previousMessages:)``, the framework only
considers a limited number of provided previous messages. `previousMessagesLimit` represents
this limit. The framework ignores any older messages that exceed it.
The value of `previousMessagesLimit` may change between OS releases. Read it at runtime rather than
hardcoding a limit to avoid constructing ``SuggestedActionsMessage`` instances that
the framework doesn't use, as shown in the following example:
```swift
let previousMessages = allPreviousMessages
.suffix(SuggestedActionsMessage.previousMessagesLimit)
.map(\.suggestedActionsMessage)
SuggestedActionsView(
message: message.suggestedActionsMessage,
previousMessages: previousMessages
)
```
Creates a representation of a message that the system uses to display suggested actions.
- Parameters:
- id: A stable, unique identifier for the message. Common types for this identifier are
`String`, `UUID`, or a custom identifier type, but any `Hashable`
value works. The identifier must remain consistent across the lifetime of
the message and across app launches.
- date: The date when the sender sent the message or the date your app
received it.
- subject: The subject line of the message.
- body: The body content of the message.
- sender: The participant who sent the message.
- recipients: The participants who received the message.