# User Mentions

## Overview

You can mention users in both **activities** and **comments**. When you include `mentioned_user_ids`, the API stores the mentions and returns enriched `mentioned_users` in the response. Optionally, you can create [notification activities](https://getstream.io/activity-feeds/docs/ios/notification-feeds/) for mentioned users or [send push notifications](https://getstream.io/docs/platform/push-notifications/).

## Adding user mentions

`mentioned_user_ids` can only contain existing user ids, you can use [`queryUsers` endpoint](https://getstream.io/docs/platform/users/#filter-examples) to search for users to mention.

Please note that it's up to you to include user mentions (for example @Alice) in the activity/comment text, the Stream API won't modify these fields based on `mentioned_user_ids`.

### Adding an activity with mentions

```swift label="Swift"
let activity = try await feed.addActivity(
    request: .init(
        text: "Hey @bob and @alice, check this out!",
        type: "post",
        mentionedUserIds: ["bob", "alice"],
        createNotificationActivity: true
    )
)
// activity.mentionedUsers contains enriched user objects
```

### Adding a comment with mentions

```swift label="Swift"
let comment = try await feed.addComment(
    request: .init(
        comment: "Thanks @bob for the tip!",
        objectId: "activity_123",
        objectType: "activity",
        mentionedUserIds: ["bob"],
        createNotificationActivity: true
    )
)
// comment.mentionedUsers contains enriched user objects
```

## Reading mentioned users

Activities and comments returned by the API include a `mentioned_users` array with enriched user objects (id, name, image, etc.). Use them to render @mentions in your UI.

```swift label="Swift"
// From activities
let feedResponse = try await feed.getOrCreate()
for activity in feedResponse.activities {
    if let mentioned = activity.mentionedUsers, !mentioned.isEmpty {
        print("Mentioned: \(mentioned.map(\.name).joined(separator: ", "))")
    }
}
// From comments (e.g. activity with latest replies)
let activity = try await feed.getActivity(activityId: "activity_123", withReactions: false, withReactionCounts: false, withRecentReplies: 10)
for comment in activity.latestReplies ?? [] {
    if let mentioned = comment.mentionedUsers, !mentioned.isEmpty {
        print("Comment mentioned: \(mentioned.map(\.name).joined(separator: ", "))")
    }
}
```

## Mentions in notification feed

- **Activities:** When `create_notification_activity` is `true`, each mentioned user receives a `mention` notification in their notification feed.
- **Comments:** When `create_notification_activity` is `true`, each mentioned user receives a `comment_mention` notification (the activity author does not get an extra notification for mentions; they already get a comment notification).

For updating or deleting activities/comments and managing mention notifications (e.g. `handle_mention_notifications`, `delete_notification_activity`), see [Notification feeds](https://getstream.io/activity-feeds/docs/ios/notification-feeds/).

## Push notifications

Use the `skip_push` parameter to control if push notifications are sent to mentioned users or not. For more information check the [Push notification guide](https://getstream.io/docs/platform/push-notifications/) that contains all relevant information about setting up push notification providers, customizing notifications and user preferences.

---

For the most recent version of this documentation, visit [https://getstream.io/activity-feeds/docs/ios/user-mentions/](https://getstream.io/activity-feeds/docs/ios/user-mentions/).