Mentions enable users to tag other community members in posts, creating direct engagement opportunities and enhancing social interaction. The social.plus SDK provides comprehensive mention functionality with metadata support for custom rendering and notification systems.
Modify existing posts to add, remove, or update user mentions while maintaining post integrity.
The pattern for adding mentions to posts is consistent across all post types (text, image, video, file). The examples show text posts, but the same creation process applies to any post type.
iOS
Android
TypeScript
Flutter
Copy
Ask AI
// Update existing post with new mentionsfunc updatePostWithMentions( postId: String, newText: String, mentionedUserIds: [String], completion: @escaping (Result<AmityPost, Error>) -> Void) { // Build updated mention metadata let mentionMetadata = buildMentionMetadata(text: newText, userIds: mentionedUserIds) let builder = AmityTextPostBuilder() .setText(newText) .setMentionUsers(mentionedUserIds) .setMetadata(mentionMetadata) let repository = AmityPostRepository(client: client) repository.editPost(withId: postId, builder: builder) .subscribe { result in completion(result) }}// Remove all mentions from a postfunc removeMentionsFromPost( postId: String, newText: String, completion: @escaping (Result<AmityPost, Error>) -> Void) { let builder = AmityTextPostBuilder() .setText(newText) .setMentionUsers([]) // Empty mention list .setMetadata([:]) // Empty metadata let repository = AmityPostRepository(client: client) repository.editPost(withId: postId, builder: builder) .subscribe { result in completion(result) }}
For comprehensive mention rendering guidelines, including metadata structure, custom mention objects, and UI implementation patterns, refer to the Mentions Guide documentation.
class MentionInputViewController: UIViewController { @IBOutlet weak var textView: UITextView! private let mentionManager = PostMentionManager() func textView(_ textView: UITextView, shouldChangeTextIn range: NSRange, replacementText text: String) -> Bool { let currentText = textView.text as NSString let updatedText = currentText.replacingCharacters(in: range, with: text) // Check if user is typing a mention if text == "@" { showUserSuggestions() } else if updatedText.contains("@") { updateUserSuggestions(for: updatedText) } return true } private func showUserSuggestions() { // Show user picker or autocomplete list } private func updateUserSuggestions(for text: String) { let mentions = mentionManager.extractMentionsFromText(text) // Update suggestion list based on partial mentions }}
Notification Behavior: When updating posts with mentions, the mentioned users will NOT receive new notifications. Mention notifications are only sent when posts are initially created.
Cross-Platform Consistency: The mention metadata structure is consistent across all platforms, enabling seamless mention rendering regardless of the client implementation.