Enable rich emotional responses to posts, stories, and comments through a comprehensive reaction system. Manage reactions with querying capabilities, add/remove functionality, and detailed analytics to foster engagement and community interaction.

Query Reactions

Retrieve detailed information about reactions on posts, stories, and comments

Add Reactions

Allow users to express emotions with custom reaction names

Remove Reactions

Enable users to change or remove their reactions

Query Reactions

To further facilitate the management of reactions in your app, the social.plus SDK includes a getReactions method that allows you to retrieve information about a specific reaction or all reactions on a comment, post, or story. Using this method, you can fetch detailed information about:

Reference Types

The referenceType parameter determines the type of reference for which reactions are queried. Supported values are:
Reference TypeDescription
postRetrieves reactions for a post
storyRetrieves reactions for a story
commentRetrieves reactions for a comment
messageRetrieves reactions to a message

Parameters

ParameterTypeRequiredDescription
referenceIdStringYesID of the post, comment, story, or message
referenceTypeEnumYesType of content being queried for reactions
reactionNameStringNoFilter by specific reaction type (case-sensitive)
var token: AmityNotificationToken?

// Query all reactions for a post
token = reactionRepository.getReactions(
    "<post-id>",
    referenceType: .post,
    reactionName: nil
).observe { liveCollection, changes, error in
    // Handle result here
    guard let reactions = liveCollection.object else { return }
    
    for reaction in reactions {
        print("User: \(reaction.userId)")
        print("Reaction: \(reaction.reactionName)")
        print("Created: \(reaction.createdAt)")
    }
}

// Query specific reaction type
token = reactionRepository.getReactions(
    "<post-id>",
    referenceType: .post,
    reactionName: "like"
).observe { liveCollection, changes, error in
    // Handle filtered results
}

Add / Remove Reactions

The social.plus SDK provides comprehensive functionality for adding and removing reactions on posts. Users can add multiple reactions to express themselves more expressively and remove reactions for greater control over their engagement.

Add Reaction

The addReaction function allows users to add a reaction to a post, comment, story, or message. Users can add any number of reactions to a particular piece of content, enabling more nuanced and expressive engagement.

Key Features

Parameters

ParameterTypeRequiredDescription
reactionNameStringYesName of the reaction (max 100 characters, case-sensitive)
referenceIdStringYesID of the post, comment, story, or message
referenceTypeEnumYesType of content receiving the reaction

do {
    let result = try await reactionRepository.addReaction("<reaction-name>", referenceId: "<post-id>", referenceType: .post)
} catch {
    // Handle error here
}

Remove Reaction

The removeReaction function allows users to remove a previously added reaction from a reference. This provides users with greater control over their engagement and allows them to change their minds or update their reactions over time.

Parameters

ParameterTypeRequiredDescription
reactionNameStringYesName of the reaction to remove (case-sensitive)
referenceIdStringYesID of the post, comment, story, or message
referenceTypeEnumYesType of content where the reaction will be removed
Case Sensitivity: Reaction names are case sensitive. “like” and “Like” are treated as two different reactions, so ensure exact matching when removing reactions.
do {
    let result = try await reactionRepository.removeReaction("<reaction-name>", referenceId: "<post-id>", referenceType: .post)
} catch {
    // Handle error here
}

Common Reaction Types

Best Practices

Use Cases

Social Feeds

Enable reactions on posts in social media feeds

Content Moderation

Use reaction patterns to identify popular or problematic content

Community Engagement

Foster community interaction through expressive reactions

Content Analytics

Analyze user sentiment and content performance

Gamification

Use reactions as part of engagement and reward systems

Feedback Loops

Gather user feedback on different types of content